UI Action Help

DKSINGH
Tera Contributor

Hi All,

Need help in correction of script.
I have written, below UI Action script to retrieve Assignment Group values, according to Business Unit. But when I click on UI Action it gives error

DKSINGH_0-1719932206661.png

** User who is clicking the button is member of group.. & I also tried using assignment group SYS_ID

-------------------------------------------------------

Script

----------

(function executeUIAction(current) {

    var businessUnit = current.u_business_unit;

    // Map business unit to assignment group
    var assignmentGroup;
    switch (businessUnit) {
        case 'CH':
            assignmentGroup = 'AML_L2_CH_SUP';
            break;
        case 'SG':
            assignmentGroup = 'AML_L2_SG_SUP';
            break;
        case 'NL':
            assignmentGroup = 'AML_L2_NL_SUP';
            break;
        case 'FR':
            assignmentGroup = 'AML_L2_FR_SUP';
            break;
        case 'HQ':
            assignmentGroup = 'AML_L2_HQ_SUP';
            break;
        default:
            // Handle any other cases or set a default assignment group
            assignmentGroup = 'Default_Assignment_Group';
            break;
    }
    current.assignment_group = assignmentGroup;
    current.assigned_to = gs.getUserID();
    current.update();
    action.setRedirectURL(current);
})(current);

 

 

2 REPLIES 2

Robbie
Kilo Patron
Kilo Patron

Hi @DKSINGH,

 

From reading your script, this is data related and something you need to factor in when setting the Assignee.

You're attempting to set the Assignment Group and the Assignee, however it seems another rule (which is not uncommon) is kicking in preventing you to add an Assignee that is not a member of the group you've just set.

 

So as to check the theory, can you comment the line where you set the assignee or simply clear the assignee value:

- current.assigned_to = gs.getUserID(); comment out this line using // or

- current.assigned_to = '';

 

Or control the data so that you set the Assignee to be a member of the Assignment Group that you're setting.

You'll have to implement this logic into your code if required.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.


Thanks, Robbie

DKSINGH
Tera Contributor

Hi Robbie,

Now I am getting different issue, I used 

current.assigned_to = '';  - Assignee Error is gone

 

But now,  It is now creating duplicate records with blank Assignment Group & Assignee. 
Any suggestion further ?