How exactly delta.isFieldChanged() method works?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
How exactly delta.isFieldChanged() method works?
Hello team,
Could anybody explain the way these methods work?
var isFieldChanged = delta.isFieldChanged(myTextField);
var isFieldReallyChanged = delta.isFieldReallyChanged(myTextField);
They always return FALSE even if I edited myTextField. Why?
The idea is to use an own way of "item is edited" process calculation.
Using of "Significant Change Since Item Revision" field is not suitable for some reason.
Regards
Solved! Go to Solution.
- Labels:
-
Requirements & Validation
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
It is basically same logic but the call to the method appears wrong, as it does not reference delta and gets no field value.
eb = bsf.lookupBean("siEnvironmentBean");
sb = bsf.lookupBean("imServerBean");
delta = bsf.lookupBean("imIssueDeltaBean");
eb.setMessageCategory("DEBUG");
logging = eb.messageCheck();
if (logging) {
eb.print("DELTATEST RUNNING");
eb.print("Running for item " + delta.getID());
}
eb.print("old: "+ delta.getOldFieldValue("Text"));
eb.print("new: "+ delta.getNewFieldValue("Text"));
eb.print("set to old value: "+ delta.getOldFieldValue("Text"));
delta.setFieldValue("ALM_Text",delta.getOldFieldValue("Text"))
eb.print("changed: "+ delta.isFieldChanged("Text"));
eb.print("really changed: "+ delta.isFieldReallyChanged("Text"));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello.
precondition is a PRE trigger.
isFieldChanged returns true if the field was touched; so any modification will result in 'true'
isFieldReallyChanged returns true only if the value was finally changed to be different than before; so changing value and changing back will result in 'false'
As an example, I used default Text field which of course is rich text and a FVA.
Initial value before change was 'Hi' and I changed it to 'Hello':
2025-01-13 11:15:00,358 DEBUG [mksis.IntegrityServer] DEBUG(5): Administrator[RMI Executor-thread-2]: Rule -11 = 10 evaluated true, triggering Trigger: REQ_delta
2025-01-13 11:15:00,358 DEBUG [mksis.IntegrityServer] DEBUG(0): Administrator[RMI Executor-thread-2]: REQ_delta
2025-01-13 11:15:00,359 DEBUG [mksis.IntegrityServer] DEBUG(5): Administrator[RMI Executor-thread-2]: Trigger "delta_set_REQ.js" - DELTATEST RUNNING
2025-01-13 11:15:00,359 DEBUG [mksis.IntegrityServer] DEBUG(5): Administrator[RMI Executor-thread-2]: Trigger "delta_set_REQ.js" - Running for item 149979
2025-01-13 11:15:00,359 DEBUG [mksis.IntegrityServer] DEBUG(5): Administrator[RMI Executor-thread-2]: Trigger "delta_set_REQ.js" - old: <!-- MKS HTML --><p>Hi</p>
2025-01-13 11:15:00,359 DEBUG [mksis.IntegrityServer] DEBUG(5): Administrator[RMI Executor-thread-2]: Trigger "delta_set_REQ.js" - new: <!-- MKS HTML --><p>Hello</p>
2025-01-13 11:15:00,359 DEBUG [mksis.IntegrityServer] DEBUG(5): Administrator[RMI Executor-thread-2]: Trigger "delta_set_REQ.js" - set to old value: <!-- MKS HTML --><p>Hi</p>
2025-01-13 11:15:00,359 DEBUG [mksis.IntegrityServer] DEBUG(5): Administrator[RMI Executor-thread-2]: Trigger "delta_set_REQ.js" - changed: true
2025-01-13 11:15:00,359 DEBUG [mksis.IntegrityServer] DEBUG(5): Administrator[RMI Executor-thread-2]: Trigger "delta_set_REQ.js" - really changed: false
isFieldChanged returns true as the field was modified/touched but isFieldReallyChanged gives false as the value is same as before.
Hope that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello pal,
Many thanks for your answer,
Can you share your code as mine doesn't work as expected ? 😞
****************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
It is basically same logic but the call to the method appears wrong, as it does not reference delta and gets no field value.
eb = bsf.lookupBean("siEnvironmentBean");
sb = bsf.lookupBean("imServerBean");
delta = bsf.lookupBean("imIssueDeltaBean");
eb.setMessageCategory("DEBUG");
logging = eb.messageCheck();
if (logging) {
eb.print("DELTATEST RUNNING");
eb.print("Running for item " + delta.getID());
}
eb.print("old: "+ delta.getOldFieldValue("Text"));
eb.print("new: "+ delta.getNewFieldValue("Text"));
eb.print("set to old value: "+ delta.getOldFieldValue("Text"));
delta.setFieldValue("ALM_Text",delta.getOldFieldValue("Text"))
eb.print("changed: "+ delta.isFieldChanged("Text"));
eb.print("really changed: "+ delta.isFieldReallyChanged("Text"));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Mega thanks!
Best!
