Skip to main content
Question

Set default value with workflows of type Date


Forum|alt.badge.img+6

Hi everyone.

I’m trying to set some default values for the multilevel promotion flow

For this four values I have no problem.

execution.setVariable('StructureManufacturing', true);
execution.setVariable('RoutingManufacturing', true);
execution.setVariable('StructureStatus', 'Buildable');
execution.setVariable('RoutingStatus', 'Buildable');

But for the date I receive an error.

When I use this statement :
var now = new java.util.Date();
execution.setVariable('EffectiveDate', now);

I receive following error
The Camunda Attribute EffectiveDate has a type of DATE but the provided value does not match that type.

When I use this statement :

var sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
var today = sdf.format(new java.util.Date());
execution.setVariable("EffectiveDate", today);

I receive following error 

This error happens when the server cannot serialize the data to be sent to the client.

What is correct way to set a default value to field of type date?

8 replies

Forum|alt.badge.img+2
  • Do Gooder (Employee)
  • 9 replies
  • April 17, 2025

Hi ​@ZFTKMARTELE 

There is a post about how to use dates and timestamps in workflows. You can get an idea from that.
https://oneifs.workplace.com/groups/352666655725801/permalink/1174556653536793/

 

I have created a sample workflow to set the date as a default value. Hope this helps you.

  1. Use script task to set the date

 

  1. By using the Process Enrichment task, register the variable.

 

  1. Set the projection action with action type CALL and call name must be default method of the respective entity.
     

 

  1. Result

     


 


Forum|alt.badge.img+6
  • Author
  • Do Gooder (Customer)
  • 15 replies
  • April 17, 2025
pdollk wrote:

Hi ​@ZFTKMARTELE 

There is a post about how to use dates and timestamps in workflows. You can get an idea from that.
https://oneifs.workplace.com/groups/352666655725801/permalink/1174556653536793/

 

I have created a sample workflow to set the date as a default value. Hope this helps you.

  1. Use script task to set the date

 

  1. By using the Process Enrichment task, register the variable.

 

  1. Set the projection action with action type CALL and call name must be default method of the respective entity.
     

 

  1. Result

     


 

Hi,

Thanks for the response and sample.

But I have still receive an error.
See my code and debug values.

Date is correct and filled in

 

 

But I still receive error when trying to execute my workflow.
 

 

Extra screenshots

 


Forum|alt.badge.img+2
  • Do Gooder (Employee)
  • 9 replies
  • April 17, 2025

Hi ​@ZFTKMARTELE ,

I tried with the same workflow I created in the previous example to set the default value for EffectiveDate using IfsApp.MultilevelPromotionHandling.MultilevelPromotionVirtual_Default().
I tested it in one of the master dev environments, and the EffectiveDate was set as expected.

 

Workflow settings

 

 

Projection Action 

 

Result

 

OData Response

 

As I can see in your screenshots after debugging, there are no visible issues.
A few questions:

  1. What track are you working on? It might be a track-specific issue, but not sure.

  2. If you remove the EffectiveDate, are the other values being set correctly?

  3. Have you checked the Network tab in the browser's debug console (Inspect)? Is there any exception logged?


Forum|alt.badge.img+6
  • Author
  • Do Gooder (Customer)
  • 15 replies
  • April 17, 2025

Hi ​@pdollk 

 

What is RegulatoryBodyHandling because I don’t have that projection in IFS. We are currently on version 23R1SU7 and we will go soon over to 23R1SU23. We are in Belgium can it be something to do with regional settings?

I’m also using 

IfsApp.MultilevelPromotionHandling.MultilevelPromotionVirtual_Default(). I made the projection action again to be sure but same problem

  1. What track are you working on? It might be a track-specific issue, but not sure.

    1.  What do you mean with that?

  2. If you remove the EffectiveDate, are the other values being set correctly?

    1. It works perfect without the date

  3. Have you checked the Network tab in the browser's debug console (Inspect)? Is there any exception logged?

 


Forum|alt.badge.img+2
  • Do Gooder (Employee)
  • 9 replies
  • April 17, 2025

Hi ​@ZFTKMARTELE ,

When I recreated this scenario in the 23R1 central dev environment, I encountered the exact same issue. Then I looked into a defect we had previously fixed related to default calls. There is a similar defect that matches your case, but not 100% sure.

It occurs due to a mismatch in the return type of the object which prevents setting default values for timestamp and date attributes via workflow. If that’s the root cause of your issue, it might also be present in the 23R1SU23 version.

This issue was fixed in 24R1 onwards by setting the expected object type for all attributes before the request reaches the OData layer. I believe this fix could also resolve your issue, but further investigation is needed.

If you don’t have a workaround or alternative solution, you can raise a support ticket.


furthermore,

  • Don’t worry about the RegulatoryBodyHandling projection — I used it just for testing.

  • This issue is not dependent on regional settings.

  • By track, I meant the version. As you said, your current track is 23R1.
     

🙂


Forum|alt.badge.img+6
  • Author
  • Do Gooder (Customer)
  • 15 replies
  • April 17, 2025

Hi, ​@pdollk 

Thanks for the info and the support.
It is not that big problem (just one click more) and I’m happy that the other values are filled in, that saves me more time.

I will park this problem for the moment and will test it again in 24R1, we are starting to prepare everything and do heavy testing in the coming weeks.

Thanks again and have a good day


Forum|alt.badge.img+6
  • Sidekick (Customer)
  • 19 replies
  • June 30, 2025

Hi ​@pdollk

Piggybacking on this thread because i am having a similar issue. I have a DateTime field that I’d like to default to the current date/time on new record. I have already tested a workflow to default to the current user, so I am familiar with the “default values” flow (i have “deactivated” the user portion for my date testing). 

 

Here’s my workflow (and current date creation):

 

Setting IFS field:

 

Process Enrichment Node:

 

When i publish the workflow and trigger it with a new record, i receive this error:

 

This is what the inspection data looks like on my final node: 


Am I missing a step that converts the Locale string back to a TIMESTAMP object? 

For reference, I am on 24R2.5.

Thanks!

 

P.S. I dont think customers have access to that workplace link you added in the original response. 

 


Forum|alt.badge.img+2
  • Do Gooder (Employee)
  • 9 replies
  • July 9, 2025

 

Hi ​@mdezzi 

As shown in the image, your default date is coming in format like Wed Mar 20 2025 00:00:00 GMT+0000 (UTC).
You need to convert the date/time values into formats that are supported by Camunda.

The generally accepted formats for workflows are:

  • Date formats:

    • dd/MM/yyyy (e.g., 22/09/2023)

    • yyyy-MM-dd (e.g., 2023-09-22)

  • Datetime formats:

    • yyyy-MM-dd-HH.mm.ss (e.g., 2023-09-22-07.04.39)

    • yyyy-MM-dd-HH.mm.ss.SSSSSSS (e.g., 2023-09-22-07.04.39.0000000)

 

I believe you can adapt the JavaScript code below with slight modifications to suit your specific use case.

// Input date string
var dateString = 'Wed Mar 20 00:00:00 IST 2024';
 
// Create a mapping for months abbreviation to numeric value
var monthMap = {
  'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06',
  'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'
};
 
// Split the input date string by spaces
var parts = dateString.split(' ');
 
// Extract day, month, and year from the parts
var day = parts[2];
var monthAbbreviation = parts[1];
var year = parts[5];
 
// Get the numeric month value from the monthMap
var month = monthMap[monthAbbreviation];
 
// Create the formatted date string (dd/mm/yyyy)
var formattedDate = day + '/' + month + '/' + year;
 
// Set the formatted date to a Camunda process variable
execution.setVariable('formattedDate', formattedDate);

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings