Assign value to document_id field using script

G Balaji
Kilo Guru

Hi,

We're creating a profile(GRC module) from our custom table. While creating a record in profile table using scripts, "applies_to" field(document_id data-type)  is not getting populated if I assign sys_id of the record.

How to create record in profile table using scripts?

Thanks.

1 ACCEPTED SOLUTION

G Balaji
Kilo Guru

There's a field name Table in sn_grc_profile table and i set the field to the current table name and set applies_to to the record's sysid.

Above steps helped me to set the document id.

View solution in original post

4 REPLIES 4

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Hi,

 

To be able to use a document_id field you also need to have a table field on the table so it know which table the sys_id belongs to. 

Here is a good example how to setup that: Document ID field | ServiceNow Docs

and here is a good example how to write the script: How to set a value to a document ID field using script - Developer Community - ServiceNow Community

 

//Göran

Thanks for the response, Goran.

Documentid field could be dynamically constructed ie. table name + sysid and saved in a string field?

Since table has already been created, now I don't have liberty to modify the table design(technically yes, but not in business perspective).

 

G Balaji
Kilo Guru

There's a field name Table in sn_grc_profile table and i set the field to the current table name and set applies_to to the record's sysid.

Above steps helped me to set the document id.

Hello Balaji,

I have one issue while set  RITM reference to the field "Approving"("document_id") in "sysapproval_approver" table .

i have done below script , but it is not working.
var  gr = new GlideRecord("sysapproval_approver");
gr.document_id = RITM_sys_id;
gr.update();

 

could you please help me on that

Thanks in Advance,
Raghav