Sometimes it happens you clicks on a button on an applet which is supposed to do some modification on the current record but you get an error saying : The selected record has been modified by another user. This happens when the same record has been updated into the database (by another user or some other process like Workflow, EAI etc) and system is trying to update the old context of record on the UI. So the better way to get the updated copy of the record by refreshing it and then do any modifications. But the bottom line is you should not loose the context of the current record, so if you are thinking of using ClearToQuery() and ExecuteQuery(), it will not solve the purpose here.
There are few possible ways by which you can refresh a record on the UI, without loosing the context of the current record, depending upon the requirement you can take the decision which one to use.
1. RefreshRecord : Business Component MethodThis is a method available on Business Component which are derived from CSSBCBase class. Here is how you can use it, if writing code in PreInvokeMethod of applet :
if (MethodName == "MyMethod")
this.BusComp().InvokeMethod("RefreshRecord");
...............................................
}
This method will just refresh the highlighed record on the UI.
2. RefreshBusComp : Business Component MethodThis is similar to RefreshRecord method available on Business Component which are derived from CSSBCBase class. The only difference is that it will refresh all the records in the current query context :
if (MethodName == "MyMethod")
{
this.BusComp().InvokeMethod("RefreshBusComp");
...............................................
}
3. FINS Teller UI Navigation : Business ServiceUnlike RefreshRecord and RefreshBusComp, this business service can be used for refreshing any applet/buscomp, no matter which class it has been derived from. The method need to use is "RefreshCurrentApplet".
if(MethodName == "MyMethod")
TheApplication().GetService("FINS Teller UI Navigation").InvokeMethod("RefreshCurrentApplet", TheApplication().NewPropertySet(), TheApplication().NewPropertySet());