Creating catalog task from workflow

sohan_snow
Tera Contributor

Hi All,

Requirement :

A variable field on RITM will have 2 options based on which 2 tasks should be configured in workflow

1) if option A is selected then TASK A should be created.

2) else if option B is selected the TASK B should be created

Overall only 1 catalog task should be created based on the selection done, How can this be achieved.

Thanks in advance,

Sohan

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi,



Please follow the below steps to achieve your requirement:



1) For example I have a Variable(Select Type Box) named "Select"on the Catalog Form having Choices "Choice 1or Choice 2". So as per your requirement, If I select the Value as "Choice 1" then Catalog Task named "Catalog Task 1" would be generated else the other one.



For this you need to use a "IF" block activity in the workflow and then based on the IF block you can link your workflow to the Respective Task as shown below:



1) Catalog Item screen shot with Demo Variable having choices as mentioned above:



find_real_file.png



Workflow:



find_real_file.png



If Block Code used above in the Workflow:



Script:



answer = ifScript();




    function ifScript() {


          if(current.variables.Select == 'choice1') {           // Replace your Variable Value and Choice Value in place of Select and Choice1


                return 'yes';


          }


          return 'no';


    }



find_real_file.png



Hope this helps.Mark the answer as correct/helpful based on impact.




Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

3 REPLIES 3

shloke04
Kilo Patron

Hi,



Please follow the below steps to achieve your requirement:



1) For example I have a Variable(Select Type Box) named "Select"on the Catalog Form having Choices "Choice 1or Choice 2". So as per your requirement, If I select the Value as "Choice 1" then Catalog Task named "Catalog Task 1" would be generated else the other one.



For this you need to use a "IF" block activity in the workflow and then based on the IF block you can link your workflow to the Respective Task as shown below:



1) Catalog Item screen shot with Demo Variable having choices as mentioned above:



find_real_file.png



Workflow:



find_real_file.png



If Block Code used above in the Workflow:



Script:



answer = ifScript();




    function ifScript() {


          if(current.variables.Select == 'choice1') {           // Replace your Variable Value and Choice Value in place of Select and Choice1


                return 'yes';


          }


          return 'no';


    }



find_real_file.png



Hope this helps.Mark the answer as correct/helpful based on impact.




Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Thanks a lot sholke, that was exactly what I was looking for. Your screenshots saved me a lot of time


Paramahanns
Tera Expert

Hi Sohan,



Please use a run script activity and you can write the script as needed.



if(current.variables.<VariableName> == 'VALUE')
create_catalog_task('SYS_ID_OF_GROUP')




function create_catalog_task(grp){
var sc_tsk = new GlideRecord('sc_task');
sc_tsk.initialize();
sc_tsk.request = current.request;
sc_tsk.request_item = current.cat_item;
sc_tsk.priority = current.priority;
sc_tsk.assignment_group = grp;
// Add rest of fields that you would like to copy from request_item to task


sc_tsk.insert();


}



Please mark as correct or helpful based on your result.



Regards


Param