Crow Canyon Software Forum
Dates formatting in workflow
Quote from jeckard on July 11, 2022, 5:27 pmDoes anyone know what formula I could use just to get the YY-MM out of the a Due Date column? I need to add that to a string for a format of something like YY-MM_LastName_FirstName.
Thanks
Does anyone know what formula I could use just to get the YY-MM out of the a Due Date column? I need to add that to a string for a format of something like YY-MM_LastName_FirstName.
Thanks
Quote from pf-amalin on July 11, 2022, 6:36 pmconst duedate = currentItem.get_item("Due Date");
// all date parts, 2 digits:
const d = ("0" + duedate.getDate()).slice(-2);
const m = ("0" + (duedate.getMonth()+1)).slice(-2); //just to make it fun, you have to add 1 since some of these fields are zero-based
const y = duedate.getFullYear().toString().slice(-2);
const h = ("0" + duedate.getHours()).slice(-2);
const n = ("0" + (duedate.getMinutes()+1)).slice(-2); //just to make it fun, you have to add 1 since some of these fields are zero-based// get other fields
const last = currentItem.get_item("LastName");
const first = currentItem.get_item("FirstName");// put it together
const Answer = y + "-" + m + "_" + last + "_" + first
const duedate = currentItem.get_item("Due Date");
// all date parts, 2 digits:
const d = ("0" + duedate.getDate()).slice(-2);
const m = ("0" + (duedate.getMonth()+1)).slice(-2); //just to make it fun, you have to add 1 since some of these fields are zero-based
const y = duedate.getFullYear().toString().slice(-2);
const h = ("0" + duedate.getHours()).slice(-2);
const n = ("0" + (duedate.getMinutes()+1)).slice(-2); //just to make it fun, you have to add 1 since some of these fields are zero-based
// get other fields
const last = currentItem.get_item("LastName");
const first = currentItem.get_item("FirstName");
// put it together
const Answer = y + "-" + m + "_" + last + "_" + first
Quote from jeckard on July 12, 2022, 8:41 amThat works in the form itself when you open the form you can do a form event but what about in workflow? I do not see a execute script function in Workflow.
Thanks
That works in the form itself when you open the form you can do a form event but what about in workflow? I do not see a execute script function in Workflow.
Thanks
Quote from pf-amalin on July 12, 2022, 12:14 pmSorry, we use it in a form, and also in a Custom Action to update the column if needed. It's probably not the most elegant solution but it has been working for us. Maybe someone else can chime in if there's a way to execute javascript in a workflow, but I kind of doubt it since workflows are executed on the server.
Sorry, we use it in a form, and also in a Custom Action to update the column if needed. It's probably not the most elegant solution but it has been working for us. Maybe someone else can chime in if there's a way to execute javascript in a workflow, but I kind of doubt it since workflows are executed on the server.
Quote from DavisA on July 13, 2022, 9:22 amI've accomplished something similar by setting a variable using the regextract([value/placeholder],@expression) formula to strip the desired value(s) out, then using the strcat() function to combine your variable and the rest of your string.
I've accomplished something similar by setting a variable using the regextract([value/placeholder],@expression) formula to strip the desired value(s) out, then using the strcat() function to combine your variable and the rest of your string.
Quote from jeckard on July 14, 2022, 11:01 amAll
Thank you I ended up using a version of the script to update the file name pre-save in a custom action and that resolved.
Thanks
Jennifer
All
Thank you I ended up using a version of the script to update the file name pre-save in a custom action and that resolved.
Thanks
Jennifer
Quote from ACR-SCOUT on July 15, 2022, 1:19 pmAdd a calculated column to the list. Use Excel functions to format the date, something like Concate(Text([DueDate],"MM_YY"),"_","[Lastname],"_","[Firstname]).
Then use the calculated field in your workflow. Of course hide the column in any views.
Add a calculated column to the list. Use Excel functions to format the date, something like Concate(Text([DueDate],"MM_YY"),"_","[Lastname],"_","[Firstname]).
Then use the calculated field in your workflow. Of course hide the column in any views.