2

I need to set a field on the Order object using a Workflow Field Update, and the updated value should be formatted as follows:

<Account JDE Ship to number> - YYMMDDHHmmSS 

I have tried to the following formula:

Account.JDE_ship_to_account_no__c - DATETIMEVALUE()

But the formula editor gives me this error:

Error: Incorrect number of parameters for function 'DATETIMEVALUE()'.` Expected 1, received 0

How can I make this field update work?

  • 1
    Where does the date you want to put in there come from? – Alexander Aeons Torn Feb 9 '17 at 13:53
  • What is Account JDE Shipto number? Do you want your field to look like XX999 - YYMMDDHHmmSS, assuming XX999 is your Account JDE Shipto number and YYMMDDHHmmSS a date/time stamp of last value update on some field? – o-lexi Feb 9 '17 at 18:26
3

You should use something like the one here:

Formula

Account.JDE_ship_to_account_no__c + '-' + 
Right( Text( Year( Today() ) ), 2) + 
Lpad( Text( Month( Today() )), 2, '0' ) + 
Lpad( Text( Day( Today() )), 2, '0' ) + 
SUBSTITUTE(Left( Right( Text( Now() ), 9), 8), ':', '')

Result

enter image description here

Warning!

Don't be scared, just note that the time part will return the value in GMT not in your local time. Details and some very useful tips on working with date-time formulas can be found here.

| improve this answer | |
2

DATETIMEVALUE

Use: DATETIMEVALUE(expression) and replace expression with a date/time or text value, merge field, or expression.Description: Returns a year, month, day and GMT time

Link to documentation

Field Name & '-' & YYYYMMDDHHSS

Y know how to print the YYYYMMDD but i'm not sure how to print the hours and seconds on an easy way since there on build in function yet :

You can check more discussion about that here: https://developer.salesforce.com/forums/?id=906F00000008v7gIAA

For YYYYMMDD assuming you always want 2 digits on MM & DD I would use :

TEXT(YEAR(DATEVALUE(NOW()))) & IF(LEN(TEXT(MONTH(DATEVALUE(NOW()))))=1,'0'&TEXT(MONTH(DATEVALUE(NOW()))),TEXT(MONTH(DATEVALUE(NOW())))) & IF(LEN(TEXT(DAY(DATEVALUE(NOW()))))=1,'0'&TEXT(DAY(DATEVALUE(NOW()))),TEXT(DAY(DATEVALUE(NOW()))))

But probably there are more elegant ways of doing it.

| improve this answer | |
  • How to add the field as before , that field is in Number data type – SFDC Feb 9 '17 at 14:16
  • but you guided thank you but i want this format YYMMDDHHmmSS – SFDC Feb 9 '17 at 14:36
1

DATETIMEVALUE() expect a parameter Date as as String to convert to a date

Example :

DATETIMEVALUE("2005-11-15 17:00:00")

To get the current timestamp use the function NOW()

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.