How to Set Close Date at RITM level by Transform map script while you upload the data via Excel

Atik
Tera Contributor

Hello Everyone,

We have a form where they were managing the data in excel and now we have converted it to and Catalog form.

So Now they want us to convert the historical data in RITM and we are able to generate the RITM's via cart API.

 

Only the Challenge we are facing is I am not able to set the Closed Date which I am providing via excel instead of that it is setting the today's date.

 

Second issue which we are facing is We have field "Target Date" where we have UI policy running to only accept the today or future date and restrict for past date and applicable only at Task level, So when I am trying to set past dates at RITM level its setting but when I open the Task it will clear the Value as obvious due to UI policy, I just wanted to know is there any way to set there past values via Transform script or I have to remove that UI policy validation

Please help me with above.

 

Thanks in advance!
Atik Bagwan

1 REPLY 1

ifti122
Tera Guru

Hi @Atik

 

The issue is that when you set the RITM state to "Closed," ServiceNow's out-of-the-box business rules automatically set the closed_at date to the current time.

So to preserve your historical date from Excel, you need to use a server-side script (like a fix script or a script in a transform map) to update the RITM after it has been created. In your script, use autoSysFields(false) function before you call update(). This tells ServiceNow to skip updating system fields like closed_at, allowing your historical date to be saved.

Note: Double check date format as well. Transform map can handle different date formats from an excel file but If the date format is particularly complex or inconsistent, you may need to use a transform script to manually parse and format the date using JavaScript. 

If I look into your second issue, UI policy is a client-side (browser-level) script, which is why it clears the past date when you open the task form.
Set the date using a server-side script (like a transform script or fix script). Server-side operations are not affected by client-side UI policies. The value will be set correctly in the database. The UI policy will still prevent users from manually selecting a past date in the future, which is the desired behavior.

 

Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.