Loading
Feature degradation | Gmail Email delivery failureRead More
Set Up and Maintain Retail Execution
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Sample Definition to Shows Success or Failure Message for an Action

          Sample Definition to Shows Success or Failure Message for an Action

          Define a function, in this case, to handle incoming mobile links in the Consumer Goods mobile app and show the appropriate message to the user. The showMessageBox function shows a message to the user based on the success or failure of an action.

          Required Editions

          Available in: Lightning Experience

          Available in: Enterprise and Unlimited Editions that have Consumer Goods Cloud enabled

          1. In Visual Studio Code based Modeler, define an action named ShowMessageBox at src/FWDashboard/PR/FWDashboard_FWUserWelcome/FWDashboard_FWUserWelcomeProcess.processflow.xml.

            The ShowMessageBox action calls the ProcessContext::CardController.showMessageBox method with parameters success and data from the event, and transitions to the ShowFWUserWelcomeUI action. It also specifies that the linkLaunchEvent external event triggers the ShowMessageBox action.

            <Action name="ShowMessageBox" actionType="LOGIC" call="ProcessContext::CardController.showMessageBox">
                    <Parameters>
                      <Input name="success" value="event.success" />
                      <Input name="data" value="event.data" />
                    </Parameters>
                    <TransitionTo action="ShowFWUserWelcomeUI" />
                  </Action>
                </Actions>
              </Body>
              <ExternalEvents>
                <Event name="linkLaunchEvent" action="ShowMessageBox" />
              </ExternalEvents>
            </Process>
          2. Save your changes.
          3. Define the logic for the ShowMessageBox function in the src/Utilities/BO/BoCockpitHelper/Mv2/BoCockpitHelper.ShowMessageBox.bl.js contract.

            In this example, the showMessageBox function is defined to show a message to the user corresponding to the success or failure of an action. When the user action is successful, the message shows the requested data. If the action fails, the function returns an error message. The function returns the promise when the user completes the action on the message box.

            function showMessageBox(success, data){
                var me = this;
                /////////////////////////////////////////////////////////////////////////
                //     Add your customizing javaScript code below.                     //                              
                /////////////////////////////////////////////////////////////////////////
                  var promise=when.resolve();
                var buttonValues = {};
                let message = "";
                buttonValues[Localization.resolve("OK")] = "ok";
                if(success){
                    message = `payload: ${JSON.stringify(data)}`
                }
                else{
                    message = `error: ${JSON.stringify(data)}`
                }
                promise = MessageBox.displayMessage(Localization.resolve("LinkLaunchEvent_Title"), message, buttonValues);
            /*
                 //////////////////////////////////////////////////////////////////////////                                                                                          
                 //       Add your customizing javaScript code above.                    // 
                 //////////////////////////////////////////////////////////////////////////
                */
                return promise;
            }
          4. Save your changes.
          5. Create a URL or QR code to test linkLaunchEvent.
            1. Define a payload. For example, {"name": "Test", "id": 123}.
            2. Encode the payload in the simulator app browser's developer console using this JavaScript code.
              let payload = {"name":"Test","id":123} let encodedPayload = btoa(Array.from(new TextEncoder().encode(JSON.stringify(payload)),(byte) => String.fromCodePoint(byte)).join("")) let mobileLinkURL = `cgcloud://share?payload=${encodedPayload}` 
            3. Construct the mobile link URL with the encoded payload. For example, cgcloud://share?payload=eyJuYW1lIjoiVGVzdCIsImlkIjoxMjN9
          6. To build your contracts, run sf mdl build.
          7. Test the mobile link in a web browser.
            1. Navigate to the application dashboard in the simulator app.
            2. In the Developer console, select Top.
            3. Copy and run the window.handleOpenURL(mobileLinkURL) command to simulate the mobile link. For example,
              window.handleOpenURL('cgcloud://share?payload=eyJuYW1lIjoiVGVzdCIsImlkIjoxMjN9')
            Verify that a dialog box appears in the app showing the payload as text.
          8. Test the QR code in the Consumer Goods mobile app.
            1. Use a tool to create a QR code for the payload URL.
            2. Open the user welcome page in the mobile app.
            3. Scan the QR code from the mobile app and verify that a dialog box appears in the app showing the payload as text.
           
          Loading
          Salesforce Help | Article