Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

CRM JS ACTION CALL

Posted on by 160

I am calling custom action from javascript in power apps.

function InvokeAction(formContext,rc_name) {

    debugger;
    var data = {"Name":rc_name}; //Action Parameters
        if (typeof (data) === "undefined") {
            data = {
                
            };
        }
    //parameters.Target = { "@odata.type": "Microsoft.Dynamics.CRM."+logicalName+", quoteid : "+recordId+"  }; // mscrm.crmbaseentity
    var req = new XMLHttpRequest();
    req.open("POST", Xrm.Utility.getGlobalContext().getClientUrl() + "/api/data/v9.2/rc_ObservationResultAlertToDoc", true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("Accept", "application/json");
    req.onreadystatechange = function () {
        if (this.readyState === 4) {
            req.onreadystatechange = null;
            if (this.status === 200 || this.status === 204) {
                var result = JSON.parse(this.response);
                console.log(result);
                // Return Type: mscrm.new_CloneRecordResponse
                // Output Parameters
               
                console.log("sucess");


            } else {
                console.log(this.responseText);
            }
        }
    };
    req.send(JSON.stringify(data));



   
}
it is showing error [Failed to load resource: the server responded with a status of 404 ()]
Please help.
  • happysingh0009 Profile Picture
    happysingh0009 160 on at
    RE: CRM JS ACTION CALL

    Its working Now. Thanks for replying. I just created new action.

  • Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: CRM JS ACTION CALL

    and the code generated by DRB?

  • happysingh0009 Profile Picture
    happysingh0009 160 on at
    RE: CRM JS ACTION CALL

    "Execution Start: 2022-11-03 15:37:33"

    "Success"

    above is result of execution in DRB

  • happysingh0009 Profile Picture
    happysingh0009 160 on at
    RE: CRM JS ACTION CALL

    {"error":{"code":"0x8006088a","message":"Resource not found for the segment 'rc_ObservationResultAlertToDoc'."}}

    also showing above error

  • Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: CRM JS ACTION CALL

    if you copy cope from online then you can check from where you copied or use DRB.

    The code however it comes from DRB due to these lines:

    //parameters.Target = { "@odata.type": "Microsoft.Dynamics.CRM."+logicalName+", quoteid : "+recordId+"  }; // mscrm.crmbaseentity

    // Return Type: mscrm.new_CloneRecordResponse

    // Output Parameters

    because they are comment lines added automatically by DRB

  • happysingh0009 Profile Picture
    happysingh0009 160 on at
    RE: CRM JS ACTION CALL

    I want synchronous call

  • happysingh0009 Profile Picture
    happysingh0009 160 on at
    RE: CRM JS ACTION CALL

    Bounded. this is not DRB. it is from online

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: CRM JS ACTION CALL

    Hi,

    Can you try below for data parameter

    Var data={};

    data.Name=rc.name;

    Can you please show me how are you calling this function?

    Screenshot will work

  • Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: CRM JS ACTION CALL

    the call works inside DRB? you have only a single parameter? is a bound or unbound call? can you post the code generated by DRB?

  • happysingh0009 Profile Picture
    happysingh0009 160 on at
    RE: CRM JS ACTION CALL

    String type argument

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans