# UPDATEPROCESSDATA with javascript

**URL:** <https://discuss.workflowgen.com/t/updateprocessdata-with-javascript/1683>\
**Category:** Process Design\
**Created:** [September 1, 2020, 6:20pm UTC](https://discuss.workflowgen.com/t/updateprocessdata-with-javascript/1683 "2020-09-01T18:20:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ParadimeWeb](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@ParadimeWeb](https://discuss.workflowgen.com/u/ParadimeWeb)\
**Post date:** [September 1, 2020, 6:20pm UTC](https://discuss.workflowgen.com/t/updateprocessdata-with-javascript/1683/1 "2020-09-01T18:20:26Z")

</div>

I have an UPDATEPROCESSDATA action that updates data variables using javascript.

It works for TEXT data, but not for DATE or NUMERIC.

Look at this example:  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/workflowgen/original/1X/50673d197a0afda283e13e466f6b944fda36ef09.png)

The data “TEST\_TEXT” works and has the value “Hello World” in it, but the data “TEST\_DATE” is empty.

Is this a bug or am I missing something?

---

<div class="post-metadata">

**Author:** ![eddy.daouk](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.workflowgen.com/eddy.daouk/32/672_2.png) [@eddy.daouk](https://discuss.workflowgen.com/u/eddy.daouk)\
**Post date:** [September 1, 2020, 10:38pm UTC](https://discuss.workflowgen.com/t/updateprocessdata-with-javascript/1683/2 "2020-09-01T22:38:38Z")

</div>

Hi @ParadimeWeb,

.NET Date objects are not compatible with JavaScript dates.  
The returned JavaScript date in your case is considered as a text string, and since the object is expecting a Date object, it is not maintaining the returned results.

As mentioned in the document, only TEXT process data types support JavaScript expressions:  
[https://docs.advantys.com/workflowgen-administration-module-reference-guide/workflow/parameters#editing-parameter-expressions](https://docs.advantys.com/workflowgen-administration-module-reference-guide/workflow/parameters#editing-parameter-expressions)

For your case I would use the **System.DateTime** macro which will return to you the current date.

Regards,  
Eddy.

---

<div class="post-metadata">

**Author:** ![ParadimeWeb](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@ParadimeWeb](https://discuss.workflowgen.com/u/ParadimeWeb)\
**Post date:** [September 2, 2020, 1:19am UTC](https://discuss.workflowgen.com/t/updateprocessdata-with-javascript/1683/3 "2020-09-02T01:19:24Z")

</div>

OK, I need to calculate the next Sunday. The workflow above was just an example.

How would you calculate the next Sunday without scripting language?

---

<div class="post-metadata">

**Author:** ![eddy.daouk](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.workflowgen.com/eddy.daouk/32/672_2.png) [@eddy.daouk](https://discuss.workflowgen.com/u/eddy.daouk)\
**Post date:** [September 2, 2020, 7:19pm UTC](https://discuss.workflowgen.com/t/updateprocessdata-with-javascript/1683/4 "2020-09-02T19:19:54Z")

</div>

Hi @ParadimeWeb,

Lucky for you, I’m working on a very similar project where I use a custom application to achieve this.

Here is my simplified code:

```auto
DateTime today = DateTime.Today;
int daysTillSunday = 0 - (int)today.DayOfWeek;
if(daysTillSunday < 0) daysTillSunday += 7;
return today.AddDays(daysTillSunday);

```

You can add this code in .NET code behind or using a custom application.

Here is a Microsoft doucmentation that shows the indexes of each day:

> **[DayOfWeek Enum (System)](https://docs.microsoft.com/en-us/dotnet/api/system.dayofweek?view=netcore-3.1)**
>
> Specifies the day of the week.

Regards,  
Eddy.
