Need to trigger approvals in workflow based on selected values in list collector.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 05:38 AM
I have a requirement where I need to trigger approvals based on the values selected in list collector variable on catalog item. I have a list collector variable(selected_country) on catalog item refers to the country table( which contains all other countries and one option as GLOBAL also).
Then I have one table approval_users where we have two column (approver_name & country), for each country there in only one dedicated approver (for example if I have 100 countries in country table then there are 100 approvers in approval_users table). For Global also there is one approver.
In workflow I have 1st level of approval to group A. Once it is approved I need to trigger next level of approvals depend on List collector (selected_country) variable selection as below:
Case 1: if list collector (selected_country) has 5 countries selected and it does not contain "GLOBAL" ---> Then I need to trigger approvals to all the 5 approvers in approval_users table.
for example: one of the country in list collector is INDIA then approval should be triggered to that one approver from INDIA in approval_users table.
Case 2: if list collector (selected_country) has selected value as "GLOBAL" only one value and it does not contain any other countries ---> Then I need to trigger approval to that one approver is there for global in approval_users table.
Case 3: if list collector (selected_country) has 6 countries selected and also it contains value "GLOBAL" as well ---> Then I need to trigger two levels of approvals here - first approval to all other 5 country's approvers in approval_users table and 2nd approval it should go to GLOBAL approver.
for exmaple: If 3 options are selected in list collector as Global, India and Algeria then 1st level of approval should be triggered approvers in india and algeria and then 2nd level of approval will go to approver in Global.
I need assistance to configure this requirement using workflow.
Thanks in Advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 12:18 PM
Hi @sadhana ghuge ,
You can start by using Run script and use this code below
var country = current.variable.selected_country.toString();
country = country.split(",");
if (country.includes(global_sys_id) && country.length == "1")
{
workflow.scratchpad.approval1= "approver sys_id for global";
}
else if(country.includes(global_sys_id))
{
workflow.scratchpad.approval1="all approvers sys_ids except global";
//search the table for the approvers sys_ids
workflow.scratchpad.approval2="approver sys_id for global";
}
else{
//search the table for the approvers sys_ids
workflow.scratchpad.approval1="all approvers sys_ids";
}
After the run script use Approval activity by passing the scratchpad values for the approvers from the run script.
Thankyou.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 02:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 03:00 AM
Hello @Ramesh_Naidu ,
Thanks for your reply.
I'm not getting how to diffrentiate the countries approvals from 'Global'. like how to trigger approvals first to all the selected countries and lastly to global. I have 'selected_country' table, how can I trigger the approvals first to the countries and then to Global?
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 03:05 AM
You can use this type of flow.
Run script code :
Approval 1 Activity:
If condition Activity:
Approval 2 Activity:
Thankyou.