diff --git a/GlideRecord/Track any update on record/README.md b/GlideRecord/Track any update on record/README.md new file mode 100644 index 0000000000..4114b20fc9 --- /dev/null +++ b/GlideRecord/Track any update on record/README.md @@ -0,0 +1 @@ +Whenever there is any update on the current record except the comments or updated that will be tracked in the Activity log by using Before update business rule diff --git a/GlideRecord/Track any update on record/code.js b/GlideRecord/Track any update on record/code.js new file mode 100644 index 0000000000..8059e4eb8e --- /dev/null +++ b/GlideRecord/Track any update on record/code.js @@ -0,0 +1,24 @@ +(function executeRule(current, previous /*null when async*/) { + + // Add your code here + for (var x in current){ + if(x!='comments'&&x!='sys_mod_count'&&x!='sys_updated_by'&&x!='sys_updated_on'){ + if (current[x] != previous[x]) { + var currVal=current[x].getDisplayValue(); + if(current[x].getDisplayValue()==''){ + currVal='empty'; + } + if(x=='description'){ + current.comments=current[x].getLabel() +' has been updated to ' +currVal; + } + else{ + var prev=previous[x].getDisplayValue(); + if(previous[x].getDisplayValue()==''){ + prev='empty'; + } + current.comments=current[x].getLabel() +' has been updated to ' +currVal+' from '+prev; + } + } + } + } +})(current, previous);