Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

In string field not taking second value, but in log i am getting two times

Not applicable

Here in log "Names are "repeating two times, but while adding to the form in the watchlist and  description I am getting only one user name, anything wrong in the code let me know

 

var grm = new GlideRecord('customer_account');

    grm.addQuery('name', current.account.name);

    grm.query();

    gs.log('loop one' + current.account.getDisplayValue());

 

 

    if (grm.next()) {

        var grmh = new GlideRecord('customer_contact');

        //var hd = grmh.addQuery('sys_tags.0470568187e58e1075d2a9f40cbb356a','=','0470568187e58e1075d2a9f40cbb356a');

        var max = grmh.addQuery('sys_tags.0470568187e58e1075d2a9f40cbb356a', '=', '0470568187e58e1075d2a9f40cbb356a');

        max.addCondition('account', '=', current.account);

        //grmh.addEncodedQuery('account' + '=' + current.account + '^sys_tags.0470568187e58e1075d2a9f40cbb356a=0470568187e58e1075d2a9f40cbb356a');

        grmh.query();

 

 

        gs.log('loop two' + current.account.name);

        // gs.log('Names are one' + grmh.name);

 

 

        while (grmh.next()) {

            gs.log('Names are two' + grmh.name);

            current.watch_list = grmh.name;

            current.description = grmh.name;

            current.update();

}}

 

 

Can anyone help me with this how to keep two values to the field

5 REPLIES 5

Sohail Khilji
Kilo Patron

Hi @Community Alums ,

 

Please pass the current.update(); outside the while loop that must fix the issue.,...


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect