Hi @Michael Fleet ,
To set default value, you can use below design which does the same:
Here, I have set defaultdate
in inline code itself:
const rithdata = workflowContext.actions.Parse_JSON.outputs.body;
const cho_users = Array.isArray(rithdata) ? rithdata : rithdata.value;
const DeafultDate = new Date("2000-01-01T00:00:00Z");
function parseDate(rith) {
return rith.signInActivity && rith.signInActivity.lastSignInDateTime
? new Date(rith.signInActivity.lastSignInDateTime)
: DeafultDate;
}
const cho_sort_json = [...cho_users].sort((a, b) => {
const dateA = parseDate(a);
const dateB = parseDate(b);
return dateB - dateA;
});
cho_sort_json.forEach(user => {
if (!user.signInActivity) {
user.signInActivity = {};
}
if (!user.signInActivity.lastSignInDateTime) {
user.signInActivity.lastSignInDateTime = DeafultDate.toISOString();
}
});
return cho_sort_json;
Output:
If this answer was helpful, please click "Accept the answer" and mark Yes
, as this can help other community members.
If you have any other questions or are still experiencing issues, feel free to ask in the "comments" section, and I'd be happy to help.