cancel
Showing results for 
Search instead for 
Did you mean: 

sap fiori elements create custom action navigate to next page

sk_ramkumar
Participant
0 Kudos
95

Hi Experts, 

I am trying to build new fiori elements application, where I have to create custom action and in the custom action I will call cap action and expecting some response from CAP. I have to use that response as params to navigate to next object page. 

I have tried few option to like below, though my actions is called and but my invoke action promise is always going to catch with error.

 changeMaterial: function (oBindingContext, aSelectedContexts) {
          

          let sActionName = "createChangeProductRequest";
          let mParameters = {
              contexts: oBindingContext,
              model: this.getModel(),  
              label: "Change Material",
              invocationGrouping: true,
              requiresNavigation: true,
              isNavigable: true,
          };

          // Add console logging for debugging
          console.log("Invoking action with parameters:", mParameters);

          try {
            this.editFlow.invokeAction(sActionName, mParameters)
                .then((context) => {
                    // Optional handling after the promise resolves
                    console.log("Action completed successfully.", context);
                })
                .catch((err) => {
                    console.error("Unexpected error invoking action:", JSON.stringify(err, null, 2));
                });
        } catch (error) {
            console.error("Caught error during invokeAction:", JSON.stringify(error, null, 2));
            MessageBox.error("Unexpected error occurred while invoking the action.");
        }
      }

Any help would be appreciated.

 

Thanks,

Ram

View Entire Topic
umasaral
Active Participant
0 Kudos

Hi 

Please check these below steps 

StepDescriptionExample/Details
1Check Custom Action ImplementationEnsure custom action is defined in manifest.json.
  Example:
  json
"sap.ui.generic.app": {
"pages": {
"YourPage": {
"component": {
"customActions": {
"YourAction": {
"handler": "YourController.YourMethod"
}
}
}
}
}
}
2Error HandlingInspect error messages in catch block.
 Example: Check if error is due to service URL or payload. 
3DebuggingUse browser developer tools. Look for failed network requests.
 Example: Check Network tab for requests. 
4Check Set Title MethodEnsure proper parameters are passed.
 Example: Check if title is set correctly.```javascript
 function setTitle(newTitle) { 
 this.getView().getModel().setProperty("/Title", newTitle); 
 } 
5Check SAP UI5 VersionConfirm compatibility of your code with the current version.
 Example: Check sap.ui.core.version in console. 
6Refer to DocumentationUse official SAP documentation for examples and guidelines.
 Example: SAP Fiori Elements Documentationhttp://sapui5.hana.ondemand.com/#/api/sap.ui.generic.app