Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Custom Action

(0) ShareShare
ReportReport
Posted on by 10

Hi Everyone,

Need some help to call Custom Action using jaavscrcipt and pass Input parameter as String with a serialized JSON object .


Can anyone suggest me any reference for this.

Thanks,

  • Suggested answer
    Torrado Profile Picture
    Torrado 1,270 on at
    RE: Custom Action

    Hello,

    Please check this example.

    Hope this helps you.

    Please mark the answer as verified if helpful. That will help others in future.

  • Suggested answer
    PabloCRP Profile Picture
    PabloCRP 1,086 on at
    RE: Custom Action

    Hi, you didn't mention what how you are going to call it. The common way its using JS but it could be in c#, powerapp.

    here an example with JavaScript

    function callAction(parameterJSON) {
        var entity = {};
        var requestAction = {};
        requestAction.parameterJSON  = parameterJSON;
        requestAction.getMetadata = function () {
            return {
                boundParameter: null,
                operationName: "NAME OF YOUR ACTION",
                operationType: 0,
                parameterTypes: 
                    "parameterJSON": {
                        typeName: "Edm.String",
                        structuralProperty: 1
                    }
                }
            };
        };
    
        Xrm.WebApi.execute(requestAction).then(
            function (result) {
                result.json().then(
                    function (response) {
                        console.log(response);
                        //HERE YOU CAN DO WHATEVER YOU NEED WITH RESPONSE
                   }
                );
            }, function (error) {
                console.log(error);
            });
    }

    you can refer to HERE the official documentation

    regards.

    if this answered to your question please don't forget to mark it as an aswer .

  • Sahilkharbanda Profile Picture
    Sahilkharbanda 10 on at
    RE: Custom Action

    Hi,

    I have tried that but could not able to figure out the format for input parameter.

    Please check the below code snippet.

    var actionName = "msdyncrm_UpsertFile"; // Global Action Unique Name        

               //Pass the input parameters of action

              var parameters = {

                   "InputFile" : "{\"msdyncrm_name\":\"Data\",\"msdyncrm_contenttype\":\".jpeg\",\"msdyncrm_width\":10,\"msdyncrm_height\":10}"

               };

    Please refer to this doc : docs.microsoft.com/.../migrate-files

    Still giving me error.

    5543.Capture.PNG

  • Suggested answer
    meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: Custom Action

    Hi,

    the easiest way is to use the CRM Rest Builder tool: github.com/.../releases

    This tool will generate the code for you.

    Good Luck !!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans