The CreatorCon Call for Content is officially open! Get started here.

RITM variable value not updating

Bidduam
Tera Guru

I have created a custom flow action to update a variable value as shown here by @Maik Skoddow :

Set Value of a Catalog Variable at Flow Designer - ServiceNow Community

 

I have used it in the past successfully, however I've only used it as a true/false or yes/no

 

This time I am trying to set a date value and it just isn't working, even though the flow execution says that is should have.

I have also tried over writing an existing date value with the new date value, along with trying to write it into a completely new field both as a date field and a text field. I've also done a convert date to string as part of the flow.

The field in the RITM just never actually updates.

 

These are the fields I'm trying to update: (I don't care which one I need to update, one or the other is fine, just trying multiple ways)

u_start_date (date field)

u_csd (text field)

 

The flow action:

Bidduam_1-1746489830439.png

I am getting the RITM to update in a previous flow action.

 

The execution log shows that it should be working:

Bidduam_2-1746489937503.png

Ideas?

 

1 ACCEPTED SOLUTION

Bidduam
Tera Guru

@DaveMerrett & @Ankur Bawiskar 

 

So my final solution was to delete the flow I'd created and create it again. I used the exact same action to update the variable value that I'd used originally, but for some reason this time it is working 100%. Maybe I've done something slightly differently (although it looks exactly the same to me) or there was some sort of corruption in the previous flow?

 

Anyway thank you both for trying to help.

View solution in original post

9 REPLIES 9

DaveMerrett
Tera Contributor

Sounds like your having some troubles - Unfortunately you'll need to check a couple of things. 

In general can you check the following:

 

  1. Ensure Correct Data Type: Make sure the data type of the variable you're trying to update matches the field type in the RITM. For u_start_date, it should be a date type, and for u_csd, it should be a string if you're converting the date to text.

  2. Use GlideDateTime: When working with date fields, using the GlideDateTime class can help ensure the date is formatted correctly. Here's an example script to set a date value:

    var gdt = new GlideDateTime();
    gdt.setValue('2025-05-06'); // Set your desired date here
    current.u_start_date = gdt.getValue();
    current.update();
  3. Convert Date to String: If you're updating a text field with a date value, ensure the date is converted to a string in the correct format:

    var gdt = new GlideDateTime();
    gdt.setValue('2025-05-06'); // Set your desired date here
    current.u_csd = gdt.getDisplayValue();
    current.update();
  4. Check Flow Execution Logs: Review the flow execution logs to ensure the flow is executing the update step correctly. Look for any errors or warnings that might indicate why the field isn't updating.
  5. Custom Action Script: If you're using a custom action, ensure the script within the action is correctly setting the field value. Here’s an example of a custom action script: javascript (function execute(inputs, outputs) { var gdt = new GlideDateTime(); gdt.setValue(inputs.dateValue); // Assuming dateValue is passed as an input var ritm = new GlideRecord('sc_req_item'); if (ritm.get(inputs.ritmSysId)) { ritm.u_start_date = gdt.getValue(); ritm.update(); } })(inputs, outputs);

If these suggestions don't resolve the issue, it might be helpful to share more details about your flow configuration or any specific error messages you're encountering. This can provide more context to troubleshoot further.

Other than that - I would love to know what your use case is.

Cheers

David 

@DaveMerrett 

So using the flow action you should not need to scrip anything, the convert date to string is built in, you just need to choose it, which I've done when trying to add it to the string field variable, but also have tried doing it directly from a date field to a date field and still doesn't work.

 

I've checked logs and it shows that it is working, gets the right values, advises of the correct field name, just doesn't actually write to the field it has selected.

 

As far as my use case:

I have a request type that gets logged that has a preliminary date in it, that needs to be confirmed later by another team that does not have a ServiceNow fulfiller license (and this is the only thing they would potentially need it for).

So I have a second catalog item that that team can use, they input some details about the original request, I do a lookup record based on the criteria, get the record details and update the variable field with the updated/confirmed date, then close off the new request that was logged.

It's just not actually updating the variable in question.

@Bidduam 

did that flow action work when you tested?

the subflow or flow which is calling that flow action is configured to Run as System user?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@Bidduam 

there is another way to do this without a flow action i.e. use the variable ownership table

sc_item_option_mtom table stores all the variable associated with RITM, you can use lookup action in flow designer and can update the variables value in "sc_item_option"

Something like this

AnkurBawiskar_0-1746505090464.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader