sys_id of attachment

Deepthi13
Tera Expert

Hi team,

i am trying to assign attachment sys_id in to a string field, in "insert business rule on signature_image" table.

I am getting @@@@@1 , @@@@@2 , logs only, i am getting sys_id of the attachment in @@@@@2 log, but not updating in to that field

(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.log('@@@@@ABC ');
var request = new GlideRecord('sc_request');
request.addQuery('sys_id',current.document);
request.query();
if(request.next()){
gs.log('@@@@@1 ABC number '+ request.number);
gs.log('@@@@@2 ABC sys id '+current.getUniqueValue());
var id = attachementid();
if(id == 'NOValue'){
gs.log('@@@@@3'+u_current_attachment_sysid);
request.u_current_attachment_sysid = u_current_attachment_sysid;
request.update();
id = attachementid();
}
if(id != 'NOValue') {
gs.log('@@@@@4'+u_current_attachment_sysid);
request.u_current_attachment_sysid = id;
request.update();
}
}
function attachementid(){
var attachment = new GlideRecord('sys_attachment');
attachment.addQuery('table_sys_id', current.getUniqueValue());
gs.log('ABC jaifdiadsf');
attachment.query();
gs.log('@@@@@5'+u_current_attachment_sysid);
if(attachment.next()){
gs.log('@@@@@6'+u_current_attachment_sysid);
return attachment.sys_id;
}
else
gs.log('@@@@@7'+u_current_attachment_sysid);
return 'NOValue';
}
})(current, previous);

 

1 ACCEPTED SOLUTION

Hello Deepthi,

 

Could you please mark the answer as correct as we will not leave this thread unanswered

 

Regards,

Chalan

View solution in original post

31 REPLIES 31

Hi,

Please create your own question so the conversation can be tracked appropriately.

You're posting this across numerous other previously closed/answered threads.

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

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

Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

khushboo roy
Tera Contributor

Instead of writing script.

Right click on the record and click on "Copy sys id".

find_real_file.png