cancel
Showing results for 
Search instead for 
Did you mean: 

Identify change in the value of a field in c4C

Former Member
0 Kudos

Hi,

Is it possible to identify change in the value of a specific field so that we can implement certain logic based on that field change.

If we write logic in Aftermodify event, it triggers for any field value change in that node.

We've tried by querying on that node and comparing database value to current, but it is causing so many issues, when we execute query for getting database values of current instance , the current instance is getting overwritten with database values.

We've tried assigning event to the Onvalue changed property of required field in the datamodel tab of the UIdesigner, but it is triggering even on loading of the screen first time. Strangely this event also triggers as many number of times as we have items in the list , though we have changed the field value for only one item. Do you have any suggestions?

Regards

Jayasri

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hello Jayasri,

You can achieve this by adding an extension field to store the value of the standard field prior to change. After adding the extension field in the BO you can add the following code in AfterModify event.

if(this.Standard Field != this.Extension Field){

     Write your logic here

     this.Extension Field = this.Standard Field

}

Hope this helps.

Thanks & Regards,

Meghna

Former Member
0 Kudos

Hi Meghna,

Thanks a lot for the solution approach, I have this approach in mind as well but it should be possible in C4C to figure out that certain field has been changed so that any requirement specific to that field change can be easily implemented. Now the issue with this approach is, we will end up adding additional custom fields in the BO just to compare for a change in between old value and new value.

So, I would like to know if there is any solution provided in C4C or do we need to follow this approach only?

Former Member
0 Kudos

There are only two ways to evaluate a change in the BO before save

1. Meghna's approach where you add extension fields for every field you want to track the before save change. It is very simple to implement. I have an example here for Service Request. Open the SR_XBO and its aftermodify/beforesave scripts to have an example how to implement this in SDK

https://www.dropbox.com/s/trg5p4v6ci3bg3y/Y02MYQZEY_Ticket%20History%20copy.zip?dl=0

2. Your approach to query the BO (go to the database to see the actual value stored) and compare it with a retrieve of the BO (go to the in-memory cache of the BO before the save is committed to the database)

Option 1 clearly has some implementation overhead, but the advantage is it very "efficient" where on modify you can easily do an in memory compare of the current value vs. the value that was stored on the last save (stored in the extension field) without doing an expensive database query

Option 2 is more simple from a code implementation point of view, but will slow down performance as you will need to do roundtrips to the database to see the difference.

Answers (0)