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.

Function setDisplayValue is not allowed in scope XYZ

Munna1
Tera Contributor

HI Everyone,

I am trying to use setDisplayValue within workflow run script activity.

When I do so, I get the following error.
Error: Function setDisplayValue is not allowed in scope xyz__.

Is there any way to deal with this?

8 REPLIES 8

Munna1
Tera Contributor

Hi Aman

If I am trying with this -> alm.transfer_order.setDisplayValue(parentID); // obj.field_name.setDisplayValue(value)

Showing this Error Message

Error Message ->Severe inconsistency between asset and transfer order line

Hi Aman,

If I am trying with this -> 

alm.transfer_order.setDisplayValue(parentID); // obj.field_name.setDisplayValue(value);

Showing this Error Message :

Error Message ->Severe inconsistency between asset and transfer order line

As I said earlier, you can just use setValue

Just changes these as below:

var too = current.variables.to_stockroom;
var fl = current.variables.from_stockroom;
var toloc = current.variables.to_stockroom.location;
var frloc = current.variables.from_stockroom.location;
var frStockName = current.variables.from_stockroom;

 

Now, use setValue

Best Regards
Aman Kumar

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi,

Please avoid posting duplicate questions. I've answered it in the other post.

https://community.servicenow.com/community?id=community_question&sys_id=bf3ae364db985d102454e6be1396...

The cause it that there's no .setDisplayValue() in scoped application. It's only supported in Global.

Check the documentation to confirm.

https://developer.servicenow.com/dev.do#!/reference/api/sandiego/server/no-namespace/c_GlideRecordSc...

It's necessary to use setValue() or use dot notation in scoped application.

e.g.

var to = new GlideRecord('alm_transfer_order');
to.initialize();
to.from_stockroom = fl.toString();
to.to_stockroom = too.toString();
to.from_location.name = frloc.toString();
to.location.name = toloc.toString();

 

                alm.request_line = current.getUniqueValue();
                alm.transfer_order = parentID;
                alm.model = aset.model;
                alm.asset = aset;
                alm.Value.quantity_requested = 1;