- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 12:46 PM
Hello,
Is there a way within an HTML Document Template to add/map a signing date? I know this can be done on a PDF Document Template, but since what I'm generating is an offer letter there are dynamic field values and the ability to edit the document after previewing it before the document task is initiated.
I need a way to record the signing date from the subject person before the final PDF gets generated. Any ideas?
Solved! Go to Solution.
- Labels:
-
Employee Document Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2024 03:50 PM - edited 08-19-2024 04:50 AM
Here's the BR conditions and script that I use.
(function executeRule(current, previous /*null when async*/) {
var htmlBody = current.body.toString();
var curDate = new GlideDate();
var formattedDate = curDate.getByFormat('dd-MMM-yyyy');
var actionType = current.participant.toString();
if (actionType == '1450bf7c937f42d0b6c1b92b1bba10ef' && current.state.changesTo(3)) {
// Manager Acknowledgement and state changes to Closed
htmlBody = htmlBody.replace('<span style="color: #ffffff;">DateManagerAcknowledgement</span>', '<span style="color: #000000;">' + formattedDate + '</span>');
} else if (actionType == '1200bbfc937f42d0b6c1b92b1bba10bc') {
// Employee Acknowledgement
if (current.state == 1) { // Ready
var prevTask = current.previous_task.sys_id;
var prevtskQuery = new GlideRecord('sn_doc_task');
if (prevtskQuery.get(prevTask)) {
var prevtskDate = prevtskQuery.getValue('closed_at');
var prvformattedDate = new GlideDate(prevtskDate).getByFormat('dd-MMM-yyyy');
htmlBody = htmlBody.replace('<span style="color: #ffffff;">DateManagerAcknowledgement</span>', '<span style="color: #000000;">' + prvformattedDate + '</span>');
}
}
if (current.state.changesTo(3)) { // Closed
htmlBody = htmlBody.replace('<span style="color: #ffffff;">DateEmployeeAcknowledgement</span>', '<span style="color: #000000;">' + formattedDate + '</span>');
}
}
current.setValue('body', htmlBody);
current.update();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 09:54 AM
Hi @leahdany ,
After "Initiating the document task" only we can sign the PDF template which is expected OOB behavior. I don't think signing will be possible before creation of Initial Document Task.
In order to achieve you have to Customize OOB flow as per your business requirement.
Please mark helpful & correct answer if it's really worthy for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2024 08:43 PM
On the sn_doc_task, there's the "body" field that captures the html value of the document to be signed. You can create a placeholder e.g. DocumentSignDate.
Then create a Business Rule with whatever conditions you may have based on the participants, document task template etc. and do a .replace for the DocumentSignDate with the formatted date out of the document task closed/update date. That's what I have implemented and that's based on how the signature gets added to html document after signing (dig in to the flow and that's how it does it for the signature).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2024 12:02 PM
@jiral Are you able to provide the business rule you use?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2024 03:50 PM - edited 08-19-2024 04:50 AM
Here's the BR conditions and script that I use.
(function executeRule(current, previous /*null when async*/) {
var htmlBody = current.body.toString();
var curDate = new GlideDate();
var formattedDate = curDate.getByFormat('dd-MMM-yyyy');
var actionType = current.participant.toString();
if (actionType == '1450bf7c937f42d0b6c1b92b1bba10ef' && current.state.changesTo(3)) {
// Manager Acknowledgement and state changes to Closed
htmlBody = htmlBody.replace('<span style="color: #ffffff;">DateManagerAcknowledgement</span>', '<span style="color: #000000;">' + formattedDate + '</span>');
} else if (actionType == '1200bbfc937f42d0b6c1b92b1bba10bc') {
// Employee Acknowledgement
if (current.state == 1) { // Ready
var prevTask = current.previous_task.sys_id;
var prevtskQuery = new GlideRecord('sn_doc_task');
if (prevtskQuery.get(prevTask)) {
var prevtskDate = prevtskQuery.getValue('closed_at');
var prvformattedDate = new GlideDate(prevtskDate).getByFormat('dd-MMM-yyyy');
htmlBody = htmlBody.replace('<span style="color: #ffffff;">DateManagerAcknowledgement</span>', '<span style="color: #000000;">' + prvformattedDate + '</span>');
}
}
if (current.state.changesTo(3)) { // Closed
htmlBody = htmlBody.replace('<span style="color: #ffffff;">DateEmployeeAcknowledgement</span>', '<span style="color: #000000;">' + formattedDate + '</span>');
}
}
current.setValue('body', htmlBody);
current.update();
})(current, previous);