how to call ui macro from business rule or script include or scheduled job?

Community Alums
Not applicable

Hi Can any one help me on this issue,

how to call ui macro from server side script.

thanks,

Rajendra Prasad Darshanam

1 ACCEPTED SOLUTION

I did some research into this and it looks like using GlideHTTPRequest() can be difficult if the content type is Binary due to issues between Java and JavaScript. I found another post here on Community which suggests using the RESTMessageV2() Class instead. I was successfully able to download Chuck's avatar image using the following (note I used an Incident record as the target for the attachment):



var url = 'https://community.servicenow.com/people/ctomasi/avatar/80.png?a=7252';


var rm = new sn_ws.RESTMessageV2();


rm.setEndpoint(url);


rm.setHttpMethod('get');


rm.saveResponseBodyAsAttachment('incident', 'd71f7935c0a8016700802b64c67c11c6', 'chuck_image.png'); // update target details here


var response = rm.execute();


if(response.getStatusCode()==200) {


        // Success!


}



More information is available on the Product Documentation site regarding this function. Note that it is only available from Geneva onwards.


View solution in original post

13 REPLIES 13

Chuck Tomasi
Tera Patron

UI macros are something to be displayed on the screen. The scripts you mentioned are run on the server and do not present any information.



Can you provide some additional details on what you are trying to accomplish? Details (table names, catalog items, etc) are encouraged. Screen shots are always appreciated.


Community Alums
Not applicable

Thanks Chuck for your quick response,


actually i want to call pure java script code with dom elements in serverside.


so its not possible to write java script with dom elements in server scripts.


by placing the dom elements in ui macro, i want to call it from indirectly.


Thanks,


Community Alums
Not applicable

Thanks Chuck for your quick response,



actually i want to call pure java script code with dom elements in


serverside.



so its not possible to write java script with dom elements in server


scripts.



by placing the dom elements in ui macro, i want to call it from indirectly.



Thanks,



On Tue, Sep 27, 2016 at 12:48 AM, ctomasi <community-no-reply@servicenow.com


Sorry for the confusion... Don't tell me HOW you want to do something (in technical terms)... please tell me WHAT you want to do? What is the business requirement, objective here?



Example: Display an icon with a red color right after the state field on the form when the state is Overdue.