cancel
Showing results for 
Search instead for 
Did you mean: 

C4C: Workflow Rule with formula functions

yamilito01
Explorer
0 Kudos
1,624

Dear SAP team,

We have created into sales quote scenario two extension fields witch help us to monitor when an internal process start and finish, this are date/time type fields. What we need is the difference in days between this two dates, witch would result in a numeric value.

We tried using the field update workflow rule type by trying to establish a formula but the syntax error always show up

  • Field to be updated, quantity type
  • Start time field, date/time type
  • End time field, date/time type

We already tried with "Duration" and "Now" functions but they weren´t useful for our case because the result of both functions is a "date" and what we need is the difference in days between two dates, witch would result in a numeric value.

Does anyone know if this is possible to achieve and what's the correct function or syntax needed?

I´ll look forward for any useful information.

Thanks in advance for your help and best regards,

Accepted Solutions (0)

Answers (5)

Answers (5)

yamilito01
Explorer

Dear Saurabh,

We are reconsidering the PDI logic since this can´t be obtained by standard. About the Date2-Date1 we already proven (also with time2 - time 1) but always happen the same, the workflow rule run with failed result.

I really appreciate your guidance, please, if you would have any update it'll very useful to me.

Thank you again!

Regards,

yamilito01
Explorer

Dear Saurabh,

I just checked workflow log into the sales document, it seems the workflow rule ran but has a "Failed" status, check on failed link says Message"An error occured while evaluating the formula".

workflow-rule-failed-log.png


former_member226
Employee
Employee
0 Kudos

Hi Yamili,

I see, I think it is due to the fact that you are trying to find the difference between 2 timestamps i.e. TS2 - TS1 which technically is not possible to be stored in a decimal field.

For ex, TS1 is 2020-08-20T21:32:34Z, and TS2 is 2020-08-20T21:33:34Z then how can system store the value of its difference?

So in opinion, if you want to store the duration between 2 timestamps in a decimal/integer field then you should write a PDI logic (maybe you can trigger that via workflow) but that way you can have entire control over how the business logic is being processed to calculate the difference.

Alternatively, you can also give a try to see what happens when you try to subtract DATE field i.e. date2- date1. Does system calculates any difference value or it just ignores that as well?

yamilito01
Explorer

Dear Saurabh,

I really appreciate your help, It was really helpful. I tried as you said, my two date/time fields but now with a decimal type field to be updated, with this, as you showed the formula shows correct syntax. The weird thing is that it seems isn´t working the workflow rule witch should work "on every save", I assigned a value to start and end date/time fields, save and the "decimal value" field remain empty.

In your case does it work?

Thanks again and hope you can help me.

Regards,

former_member226
Employee
Employee

Hi,

Problem is with the DataType of your "Field to be updated" (Quantity) because Quantity is a compounded data type i.e. it contains Value and its UoM which you cannot calculate via the formula of "End time field, date/time type" - "Start time field, date/time type". Using a formula system is able to calculate value but unable to find any UoM associated. therefore you see an error.

In order to fix this issue, you should have the resulting field of type either NumberValue or DecimalValue or IntergerValue.

sdk-fields.png

datetime.png

date.png

teresasanchez9
Explorer
0 Kudos

Hi all,

I would appreciate your help for a workflow rule field update with a formula:

I need to calculate the multiplication of two decimal number custom fields so the formula I included was: #PRICE#*#VOLUME#

However the Syntax Check says "Syntax error in formula"

Thank you,

Best regards,