Assignment group is not populating

Samiksha2
Mega Sage

Hi all,

I have written the below code in customer service application to populate the assignment group based on custom table.

Script include

 getAssignmentGrp: function() {
        user_array = [];
        var platform = current.parent_case.u_platform;
        var product = current.getDisplayValue('parent_case.product');
        var subproduct = current.getDisplayValue('parent_case.u_sub_products');
        //gs.log('GET ASSIGNMENT platform' + platform);
        //gs.log('GET ASSIGNMENT product' + product);
        //gs.log('GET ASSIGNMENT subproduct' + subproduct);
        var dee = new GlideRecord("u_sub_product");
        dee.addEncodedQuery('u_platform=' + platform + "^u_product=" + product + "^u_sub_product=" + subproduct);
        dee.query();
        if (dee.next()) {
            user_array.push(dee.u_default_group + '');
            //.toString();
        }
        //gs.log("GET ASSIGNMENT " + user_array);
        return user_array;


    },

 

Business rule on Before

	var assignment = new sn_customerservice.getPlatform();
	var returnVal = assignment.getAssignmentGrp();
	gs.info("Business rule " + returnVal);
	current.assignment_group = returnVal;
	current.update();

 I am getting the sys_id of the group in the logs. But it is not updating the assignment group in the sn_customerservice_task table.
I thought may be application issue so I did the same thing in the Global application but still it is not updating the assignment group.

Please help

Thanks,
Sam

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You are returning Array form Script include, and then populating it on the field which can take 1 id only. Why is that?

Try this in the BR and see if that works

var assignment = new sn_customerservice.getPlatform();
	var returnVal = assignment.getAssignmentGrp();
	gs.info("Business rule " + returnVal);
returnVal =returnVal.toString().split(',');
	current.assignment_group = returnVal[0];
	current.update();

 

-Anurag

View solution in original post

5 REPLIES 5

Robbie
Kilo Patron
Kilo Patron

Hi @Samiksha2,

 

Adding to @Anurag Tripathi 's response, please note the well documented best practice not to use 'current.update()'. Why: The update() method triggers Business Rules to run on the same table for insert and update operations, potentially leading to a Business Rule calling itself over and over.

 

There is almost always an alternative way to perform the needed task in a Business Rule rather than using current.update().

In a "before" Business Rule, an update of the current record should not be necessary as the record will be saved upon completion of the highest ordered Business Rule.

 

 

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