0

I want to update the value of a text field on the Order object using Workflow Rule

Field Update should be a timestamp of the current user creating and updating the record

The datetime stamp should be in the format:

YYMMDDHHmmSS

for example:
171031121052

How i will do the field update work?

5
  • DATETIMEVALUE(expression) instead of expression you should select any DateTime field from Insert Field button. Commented Feb 10, 2017 at 4:49
  • I dont want that format 171031121052 this format only i want
    – SFDC
    Commented Feb 10, 2017 at 4:59
  • I'm happy to help with the formula, but it depends on the locale of the org/users. Are the locales (and therefore the date formatting conventions) the same for all affected users? Commented Feb 10, 2017 at 5:00
  • 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()))) like this format i want
    – SFDC
    Commented Feb 10, 2017 at 5:04
  • What are you trying to achieve through workflow? Are you trying to update some text field, with current Date and Time in format YYMMDDHHmmSS?
    – Saroj Bera
    Commented Feb 10, 2017 at 5:18

1 Answer 1

1

For US-based users (it might depend on the user locales), the formula in the workflow field update should read:

RIGHT(LEFT(TEXT(YourDateTimeField__c),4),2)
&RIGHT(LEFT(TEXT(YourDateTimeField__c),7),2)
&RIGHT(LEFT(TEXT(YourDateTimeField__c),10),2)
&RIGHT(LEFT(TEXT(YourDateTimeField__c),13),2)
&RIGHT(LEFT(TEXT(YourDateTimeField__c),16),2)
&RIGHT(LEFT(TEXT(YourDateTimeField__c),19),2)

It's ugly, but it gets the job done with the limited text functions available in Salesforce's formula editor.

4
  • Create a Workflow Rule and select "Evaluate the rule when a records is: " created, then add a Workflow Action of type "Field Update" with the option to "Use a formula to set the new value" Commented Feb 10, 2017 at 5:16
  • What date/time information are you trying to capture and save in this format? Is it the record's created date/time or some other field on the Order? Commented Feb 10, 2017 at 5:18
  • In that case replace each occurrence of YourDateTimeField__c in the formula with LastModifiedDate Commented Feb 10, 2017 at 5:24
  • Let us continue this discussion in chat. Commented Feb 10, 2017 at 5:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .