- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2020 03:27 PM
I have an onbefore transform script running, which should not update the record if the work notes are the same. The record keeps updating the work notes even if there is no change and the Source string equals the target record string.
comments in this case are >>> "Testing 123"
here is my script
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var notes = target.work_notes.getJournalEntry(1);
var worknoteContent = notes.split("(Work notes)\n");
var lastWorknote = worknoteContent[1];
// gs.log(source.u_comments);
// gs.log(lastWorknote);
if (source.u_comments == lastWorknote) {
ignore = true;
}
// Add your code here
})(source, map, log, target);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2020 08:26 AM
IF anyone is looking to compare strings in an onBefore transform script, the geniuses at SN helped me with this
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var notes = target.work_notes.getJournalEntry(1);
var worknoteContent = notes.split("(Work notes)\n");
var lastWorknote = worknoteContent[1];
var string = lastWorknote.toString();
var string1 = source.u_comments;
//gs.log("------->>> SOURCE = " + source.u_comments + "------->>> TARGET = " + lastWorknote + "-->String" + string + "-->u_comments:" + source.u_comments.toString() + "WorknoteContent:" + worknoteContent + "-->lastworkfnote:" + lastWorknote + "Equals : " + string.indexOf(string1));
// gs.info("------->>> TARGET = " + lastWorknote);
//var string1=source.u_comments.toString();
//if (string == source.u_comments.toString()) {
if (string.indexOf(string1) >= 0) {
ignore = true;
}
// Add your code here
})(source, map, log, target);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2020 08:22 AM
You are right. try this, this script should work for you.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var notes = target.work_notes.getJournalEntry(1);
var worknoteContent = notes.split("(Work notes)\n");
var lastWorknote = worknoteContent[1];
// gs.log(source.u_comments);
// gs.log(lastWorknote);
if (source.u_comments.toString() == lastWorknote.toString()) {
ignore = true;
}
}
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2020 12:49 PM
This did Not work either, record still updated again with the same comment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2020 08:26 AM
IF anyone is looking to compare strings in an onBefore transform script, the geniuses at SN helped me with this
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var notes = target.work_notes.getJournalEntry(1);
var worknoteContent = notes.split("(Work notes)\n");
var lastWorknote = worknoteContent[1];
var string = lastWorknote.toString();
var string1 = source.u_comments;
//gs.log("------->>> SOURCE = " + source.u_comments + "------->>> TARGET = " + lastWorknote + "-->String" + string + "-->u_comments:" + source.u_comments.toString() + "WorknoteContent:" + worknoteContent + "-->lastworkfnote:" + lastWorknote + "Equals : " + string.indexOf(string1));
// gs.info("------->>> TARGET = " + lastWorknote);
//var string1=source.u_comments.toString();
//if (string == source.u_comments.toString()) {
if (string.indexOf(string1) >= 0) {
ignore = true;
}
// Add your code here
})(source, map, log, target);