The Zurich release has arrived! Interested in new features and functionalities? Click here for more

service portal script

Rosy14
Tera Guru

Hi, 

I have a button in portal. when it is clecked it will remove the user .

Scenario:

 I have a record where requested for there. here there is a ref field. of that ref record there is a list type field. from this list type field that req for user also added. it should remove from that list. the button is on first form.

 

if (action == 'reject') {
qu = new GlideRecord("sn_customerservice_quotes");
qu.get(data.sys_id);
qu.query();
while (qu.next()) {

buid = qu.getValue("u_buy_plan_id");

bu = new GlideRecord("sn_customerservice_buying_event");
bu.get(buid);
bu.query();
user = [qu.getValue("contact")];
var aUtil = new global.ArrayUtil();
while(bu.next()){
var wlist = bu.getValue("u_select_buying_agent_user").toString().split(',');
gs.addErrorMessage(wlist);
bu.u_select_buying_agent_user=aUtil.diff(wlist,user).join();
}

 

Output:

 state changes to rejected but user is not removing from it. getting error.

Org.mozilla.javascript.NativeArray@13daa5f

 

plz help

2 REPLIES 2

Shoheb_IbaaBoss
Tera Guru

Hi,

Try below:

 

(function executeRule(current, previous /*null when async*/)

{

// Step 2: Retrieve the Reference Record

var referenceRecord = new GlideRecord('your_referenced_table');

if (referenceRecord.get(current.your_reference_field))

{ // Step 3: Update the List Field

referenceRecord.your_list_field.deleteRecord(current.sys_id);

// Step 4: Update the Reference Record

referenceRecord.update();

} })(current, previous);

 

Please replace 'your_referenced_table', 'your_reference_field', and 'your_list_field' with the actual names of your reference table, reference field, and list field.

 

Regards,

Shoheb

Rosy14
Tera Guru

Thank you for ur reply