Tuesday, June 25, 2024

How to Call Action from WebResource using Web Api

Introduction:


In this blog we will see how to call action from WebResource using WebApi in MSCRM or Dataverse


Implementation Steps:

 

1. Create a Action ( find my blog here on how to create Action)

 

2. I have Created an action without any input Parameters

 

rampprakash_4-1719317688631.png

 

 

3. Once the Action is Created, Navigate to Settings --> Customization --> Customize the System --> Click Web Resource

 

rampprakash_3-1719316587746.png

4. Click New and Create a New Web Resource with Below Code

 

 

var req = {};
req.getMetadata = function () {
    return {
        boundParameter: null,
        operationType: 0,
        operationName: "new_AccountAction"
    };
};
 
Xrm.WebApi.online.execute(req).then( 
    function (data) { 
        var e = data; 
        debugger; 
    }, 
    function (error) { 
        debugger; 
        var errMsg = error.message; 
    }
);

 

5. That's it.

 

Now Call this function from OnLoad Or OnSave or OnChange from Account Level.

No comments:

Post a Comment

Day 11 - Customizing Option Sets Dropdown Fields with JavaScript

  In this Blog, we will see how to Customizing Option Sets Dropdown Fields with JavaScript label1 = formContext.getAttribute( "bosch_op...