Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Gliderecord SetValue on Catalog Item variables

Tadz
Kilo Sage

Hi,

Is it possible to Gliderecord a catalog item variable value using setValue?

For example:

var variableName = 'test';

var gr = new GlideRecord('sc_task');

  gr.addQuery('request_item',current.document_id);

  gr.query();

  if(gr.next()){

gr.setValue(variableName, 'desired value');

  gr.update();

  }

Thanks,

Tadz

1 ACCEPTED SOLUTION

seanpatrick
Giga Contributor

Hi Tadz,

 

You may try this:

var variableName = 'test';

var gr = new GlideRecord('sc_task');

  gr.addQuery('request_item',current.document_id);

  gr.query();

  if(gr.next()) {

    //gr.setValue(variableName, 'desired value');

    gr.variables[variableName] = 'desired value';

    gr.update();

  }

 

__________________

Warm regards,

Sean

View solution in original post

11 REPLIES 11

Kalaiarasan Pus
Giga Sage

Is this part correct?



gr.addQuery('request_item',current.document_id);


Yes actually its working if I'm not using


var variableName = 'test';


gr.varaibles.variableName = 'desire value'; //not working



If i use:


gr.variables.<variablename> = 'desired value'; //working


gr.varaibles.variableName = 'desire value'; //not working



because spelling is wrong?



Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.


sorry its a typo in my end. I just typed that.


even


var variableName = 'test';


gr.variables.variableName = 'desire value'; //not working


Hi Kalai, i haven't revisited this. but yes this is the part that is wrong. there is no document_id in the sc_task table