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.

Accessing angular elements in onSubmit catalog clients scripts in order guides.

robertyoung
Giga Contributor

In an on-submit catalog client script you can access angular scope data with the following:  this.angular.element("#sc_cat_item").scope().data.whatever.

This does not work with order guides. I can't find any kind of handle in the SC Order Guide widget. Has anyone else had luck with that?

 

 

2 REPLIES 2

Mike Patel
Tera Sage

have you tried this.angular.element("#sc_cat_item_guide").scope().data.whatever.

Tanks for the time Mike!

These all log that there is an object returned, even the bogus one, ok fine.

console.log("1:" + this.angular.element("#sc_cat_item"));
console.log("2:" + this.angular.element("#sc_cat_item_guide"));
console.log("3:" + this.angular.element("#ThisDoesNotExist"));

The weird part is ,it ends up logging undefined if you add the .scope() to those during "onSubmit" catalog client scripts. (Obviously the "thisDoesNotExist" one should be undefined). I also tried "#orderGuideModal" with the same results. I can't help but think I've still got the wrong selector. I've cloned the widget for something unrelated, what ends up driving the element name?

 

When you control+right click and log scope and scope.data to console that DOES log the scope. I'm worried it is something specific to onSubmit catalog client scripts but I really think I've just got the wrong selector.