Code is not working to update multipul users on field

Venkataramudu A
Tera Contributor

Hi All,

 

I am using data source using excel attachment to create/update records in servicenow. i want to update multiple users on contributors field. I have written below code on field map script to udpate users based on email id. but while loading the data, script is allowing to update only one user. 

 

Below is the error message getting but user is present in user table

VenkataramuduA_2-1721908614836.png

 

 

 

Could you please suggest how to fix the issue..

 

Thanks in advance

 

VenkataramuduA_0-1721908304777.png

 

 

answer = (function transformEntry(source) {

    var contributors = [];
    var con_email = source.u_contributors.split(',');
    if (source.u_contributors) {
        for (var j = 0; j < con_email.length; j++) {
            var gr_user1 = new GlideRecord('sys_user');
            gr_user1.addQuery('email', con_email[j]);
            gr_user1.query();

            if (gr_user1.next()) {
                contributors.push(gr_user1.sys_id);

            } else {
                log.warn("Contributor "+con_email[j] + " doesn't exist in ServiceNow for policy " + source.u_name);
            }
        }

        var contributors1 = contributors.toString();
        //gs.info("$$$reviewers1" + reviewers1);
        return contributors1;
    }
    else
    {
         log.warn("Contributors are not defined for " + source.u_name+ " policy");
    }

})(source);
0 REPLIES 0