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

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.


Community Alums
Not applicable

Thanks Jake,



i want to save the image into a field in the table by saving it into


ecc_queue table,


while saving into ecc_queue we can mention the column name also.



Thanks,



On Tue, Sep 27, 2016 at 5:30 PM, jake.gillespie <


Community Alums
Not applicable

Thank you very much Jake, its working perfect.


Naveen Reddy8
Kilo Explorer

Hi,

 

I have a requirement to with catalog item. Once i submit the catalog item, it should open the chat window. as this is happening but we want the Incident number to display in the chat window automatically. the issue is at the time of submitting the form the incident wont be present and after chat is initiated the incident number is available as it takes some time to generate a record.

mean time of submit button click and the incident generation the chat is getting opened and not able to fetch the incident number.

is there a way to get it done.please help me on this.

 

Thanks,