Print Page | Close Window

Assign User especific in task

Printed From: TMS Software
Category: VCL Components
Forum Name: VCL Workflow Studio
Forum Discription:
URL: http://www.tmssoftware.com/site/forum/forum_posts.asp?TID=7228
Printed Date: 20 Oct 2019 at 1:45pm


Topic: Assign User especific in task
Posted By: belmar sigisfredo
Subject: Assign User especific in task
Date Posted: 28 Nov 2016 at 3:13am
Hi, i need assign one uses especific in task, i try add variable but to do run thi do error in user..., the user in variable is valid, but this can?t run task.

thanks



Replies:
Posted By: Wagner R. Landgraf
Date Posted: 28 Nov 2016 at 4:58pm
Hello, please give details about what and how you are trying to accomplish what you're trying to do. Nevertheless, usually the way to set the task user programmatically (before the task is created) is to put a variable name between brackets in the assigned user field (when creating the task definition):

[MyTaskUser]

and then from workflow you just need to set the value of that variable before the task block is executed (usually using a script block before the task block):

MyTaskUser := Some_User_ID;

note that the value of the variable must be the user id.


Posted By: belmar sigisfredo
Date Posted: 08 Dec 2016 at 2:54am
http://stna.cl/images/suporttms/task_definition.jpg - http://stna.cl/images/suporttms/task_definition.jpg
hi, i do this definition variable (link)

i do this code before run, this do error....

var wdf : TWorkflowDefinition;
    WorkIns: TWorkflowInstance;
    WFUsuario,WFEmail: TWorkflowVariable;
begin
     result:='';
     wdf := dmWorkFlow.WorkflowStudio.WorkflowManager.FindWorkflowDefinitionByName('Recepcion');
     if Assigned(wdf)
     then
     begin
          WorkIns:=dmWorkFlow.WorkflowStudio.WorkflowManager.CreateWorkflowInstance(wdf);
          WFUsuario:=WorkIns.Diagram.Variables.FindByName('Usuario');
          WFEmail  :=WorkIns.Diagram.Variables.FindByName('Email');
          dmWorkFlow.WorkflowStudio.WorkflowDB.WorkflowInstanceUpdate(WorkIns);
          result:=WorkIns.key;
          dmWorkFlow.WorkflowStudio.WorkflowEngine.RunWorkflow(WorkIns);
     end;




Posted By: belmar sigisfredo
Date Posted: 08 Dec 2016 at 2:57am
Originally posted by belmar sigisfredo

http://stna.cl/images/suporttms/task_definition.jpg - http://stna.cl/images/suporttms/task_definition.jpg
hi, i do this definition variable (link)

i do this code before run, this do error....

var wdf : TWorkflowDefinition;
    WorkIns: TWorkflowInstance;
    WFUsuario,WFEmail: TWorkflowVariable;
begin
     result:='';
     wdf := dmWorkFlow.WorkflowStudio.WorkflowManager.FindWorkflowDefinitionByName('Recepcion');
     if Assigned(wdf)
     then
     begin
          WorkIns:=dmWorkFlow.WorkflowStudio.WorkflowManager.CreateWorkflowInstance(wdf);
          WFUsuario:=WorkIns.Diagram.Variables.FindByName('Usuario');
          WFEmail  :=WorkIns.Diagram.Variables.FindByName('Email');
          dmWorkFlow.WorkflowStudio.WorkflowDB.WorkflowInstanceUpdate(WorkIns);
          result:=WorkIns.key;
          dmWorkFlow.WorkflowStudio.WorkflowEngine.RunWorkflow(WorkIns);
     end;




correction, this is a correct code used

function TDmWorkFlow.CreaWFRecepcion(Usuario, EMail: String): String;
var wdf : TWorkflowDefinition;
    WorkIns: TWorkflowInstance;
    WFUsuario,WFEmail: TWorkflowVariable;
begin
     result:='';
     wdf := dmWorkFlow.WorkflowStudio.WorkflowManager.FindWorkflowDefinitionByName('Recepcion');
     if Assigned(wdf)
     then
     begin
          WorkIns:=dmWorkFlow.WorkflowStudio.WorkflowManager.CreateWorkflowInstance(wdf);
          WFUsuario:=WorkIns.Diagram.Variables.FindByName('Usuario');
          WFUsuario.Value:=Usuario;
          WFEmail  :=WorkIns.Diagram.Variables.FindByName('Email');
          WFEmail.value:=EMail;
          dmWorkFlow.WorkflowStudio.WorkflowDB.WorkflowInstanceUpdate(WorkIns);
          result:=WorkIns.key;
          dmWorkFlow.WorkflowStudio.WorkflowEngine.RunWorkflow(WorkIns);
     end;
end;



Posted By: belmar sigisfredo
Date Posted: 08 Dec 2016 at 3:04am
i resolved the problem change "UserId" by   "UserName"



Print Page | Close Window