Skip to Content

SAP MDK - how does context work in change set.

Hi All,

I want to perform multiple create actions on click of a button on create.page. On searching I found ChangeSet action to do that.

But how can I manipulate data for each create action based on a multi select field on the create.page?

Regards,

Ratnakar

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Feb 23 at 03:10 PM

    Ratnakar,

    The ChangeSet Action allows you to define a "group" of transactions that must all succeed together. Meaning that if one transaction in the change set fails then all the other transactions are not applied.

    Can you elaborate on what your multiple create actions are doing? Are they really related creates? If yes the ChangeSet would be appropriate to use. If they are really independent then you can just call CreateEntity multiple times as needed.

    --Bill

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 23 at 07:24 PM

    Execute Action returns a promise which means the actual execution will occur but in an async way. Since you are looping and calling the same action, you will need to be very careful about where you data values are coming from. I am assuming you are referencing some of them from Client Data for the user specific values. This can be problematic since client data will be evaluated when the action actually executes by which time the value you really wanted to use may have changed.

    We introduced action overrides in MDK 4.3 to address this. You will want to take advantage of this to directly pass the employee specific values to your create action.

    In terms of knowing when all the creates are done, since the execute action returns a promise, you can build an array of all the promises returned and then wait for them to be completed before displaying your message.

    createPromises = [];
    for(i = 0 ; i < employee.length ; i++ ){
      context.getClientData().employee = employee[i];
      GenerareLocalId(context).then(localNumber => {
      context.getClientData().localNumber= localNumber;
      createPromises.push(context.executeAction("....Confirmation.action"));
    })
    }
    //Wait for all create actions to be executed
    return Promise.all(createPromises).then(results=> {
      return messageAction;
    }
    Add a comment
    10|10000 characters needed characters exceeded

    • You will want to change your GenerareLocalId function to internally not return until it got the new id value or change the call into an await call of your funciton rather than getting back a promise. Then you can change your main loop get the id into a local variable and call your create accordingly.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.