ServiceNow SDIM - Adding New Custom Attributes

Hi experts,

We implemented a ServiceNow SDIM in our sandbox environment and I am trying to add new custom attributes into ticket creation configuration such as “Effectivedate”. That field is defined in ServiceNow side already and when I feed this field with a static value as you can see from the screenshot, it perfectly works as expected. However, when I feed this field dynamically as following: “$!plan.arguments.effectivedate” then the ticket is being created with empty effectivedate field.

u

When I check the integration guide, it says I need to use a velocity template for a dynamic field. Only there is no example for this. I would like to get the current date (in the following format: “dd-MM-yyyy”) for the custom attribute that I want to add. Is there anyone has an example of this? Thanks in advance!

I used the following velocity expression for effectivedate :“effectivedate”: “#set($dateTool = $tools.date) #set($currentDate = $dateTool.format(‘dd-MM-yyyy’, $dateTool.date())) $currentDate”

It still fails with the error below:

Any idea?

Hi @sahincelik ,
Can you try modifying the Velocity expression to below and let me know if that works. As I believe you can directly use the ‘$dateTool.format()’ method without storing it in a variable.

"effectivedate": "#set($dateTool = $tools.date) $dateTool.format('dd-MM-yyyy', $dateTool.date())"

Hope this helps!!

Thanks for your reply. I just provided $currentDate and it worked :slight_smile:

Interesting. Any idea or any changes that were made before it was working vs now?

Yes, there is a change. My point was, instead using the entire template here: “effectivedate”: “#set($dateTool = $tools.date) #set($currentDate = $dateTool.format(‘dd-MM-yyyy’, $dateTool.date())) $currentDate”, I just sent: $currentDate and it worked.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.