cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting changes in C4C UI (Cloud Applicatin Studio)

Former Member
0 Kudos

Hello everyone,

I’m working with C4C Opportunities BO in Cloud Application Studio. I need to know if current user has make any change in Sales Team tab, inside an opportunity, so I'm checking SalesTeamParty subnode of Opportunity root node. Then, just in case the opportunity is in certain states, I must allow SalesTeamParty changes (else, not). One way is to check UI (buffer) data, and then compare it to equivalent information, previously stored in DataBase, before saving the BO.

This is the code I use to read UI (buffer) info (let's call it A):

var colInterlocutoresC4C_prueba = this.SalesTeamParty;

foreach ( var objAgenteC4C in colInterlocutoresC4C_prueba ){

var interlocutor = objAgenteC4C.Party.Employee; //get interlocutor data to compare

}

And this is the code I use to read DataBase info (let's call it B):

var sMyOpportunityID = this.ID.content;

var objQuery = Opportunity.QueryByElements;

var objSelectionParams = objQuery.CreateSelectionParams();

objSelectionParams.Add(objQuery.ID.content, "I", "EQ", sMyOpportunityID);

var objResult = objQuery.Execute(objSelectionParams);

foreach(var objOpportunity in objResult){

var colInterlocutoresC4C = objOpportunity.SalesTeamParty;

foreach(var objAgenteC4C in colInterlocutoresC4C){

var interlocutor = objAgenteC4C.Party.Employee;

//get interlocutor data to compare

}

}

The problem is that code A and code B are retrieving the same data, the data in the UI (buffer).

After searching notes about it, I found I should use ExecuteFromDB instead Execute in code B. I tried this solution, but then I found new code B was still retrieving UI (buffer) data, so I cannot compare them in order to detect user changes. This behavior is also documented here:

https://archive.sap.com/discussions/thread/3880558

Then, I found this other thread:

https://archive.sap.com/discussions/thread/3874938

Here, it's said that SAP changed ExecuteFromDB to ExecuteFromDBDataOnly, with one limitation: This function doesn't allow me to navigate through BO subnodes, only root node. As I MUST navigate to SalesTeamParty subnote (under Opportunity root node), this is not a suitable way for me.

I cannot find a way to check if Opportunity --> SalesTeamParty has changed in the UI, and I cannot find any documentation about this.

Please, can anyone point me to the right direction?

Thanks and regards,

Carlos

Accepted Solutions (0)

Answers (2)

Answers (2)

HorstSchaude
Product and Topic Expert
Product and Topic Expert

Hello Carlos,

When you trigger the "normal" query by simply Execute(...) the framework loads the retrieved instances in the buffer of the BO. Thus the previous data (from the UI) is lost.
Any query execution which loads instances is behaving the same. Therefore you need "FromDB" to get the data from the database as well as "DataOnly" to not refresh the BO buffer.

Unfortunately with the later one you get only data but not instances. Thus no navigation. 😞

As long as there is no query at the requested node you have no chance to get the data from the database.

An other way would be to have a "dummy" Custom BO which carries the the data base image. Of course this dummy BO should never be persisted.

HTH,
. Horst

Former Member
0 Kudos

Thanks for your response, Horst,

but not sure about your suggestion. I can create a custom BO with a node of SalesTeamParty, but in which moment should I populate it with data?

In the other hand, I've tried to create a transient element in Opportunity node, and give it a value in the After Loading event in main BO, but it seems I've not access to it, so I cannot fill in with original data in the After Loading and check changes when user tries to save.

Please, can you explain what you mean?

Thanks,