web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Executing custom action using javascript is failing in dynamics crm UCI page.

(0) ShareShare
ReportReport
Posted on by 5

This question is related to Dynamics CRM 365 cloud version 9.

I created a custom action namely wfrv_GetOpportunity and I wanted to execute this custom action using java script in a ribbon button command.
I created a request variable which contains the custom action name and its metadata.
Then i used web api call to execute the custom action like following.

Xrm.WebApi.online.execute(request).then(
function (result) {
if (result.ok) {
result.json().then(function (response) {
if (response.OpportunityModel) {
opportunityModelReceived = JSON.parse(response.OpportunityModel);
}
});
}
},
function (error) {
consol.log(error.message);
}
);

Everything worked fine till i used classic CRM pages.
When i migrated to UCI CRM page, the above web api call was giving error.
When i debugged found out that web api call received a error message BAD REQUEST with error code 400. I did not modify anything in the request object.

So Web api execute method for executing custom action is working fine when i use classic crm page but not working when i use UCI crm page.

Any suggestion to solve this problem will be highly appreciated.

Thanks,
Bibhu

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Can you please provide screenshot of your action and code that you use to generate request.

  • Dynamics _365_ CRM Profile Picture
    5 on at

    Hi Andrew,

    Here is the code for generating the request.

    var getOpportunity = function (action, parameters) {

                   this.OpportunityId = parameters.OpportunityId;

                   this.Lob = parameters.Lob;

                   this.ShowFinalAwardedRoleSelection = parameters.ShowFinalAwardedRoleSelection;

                   this.HasCreditFlag = parameters.HasCreditFlag;

                   this.IsMnpOpp = parameters.IsMnpOpp;

                   this.ApplicationDate = parameters.ApplicationDate;

                   this.IsLoanMod = parameters.IsLoanMod;

                   this.IsLoanOrig = parameters.IsLoanOrig;

                   this.getMetadata = function () {

                       return {

                           boundParameter: null,

                           operationType: 0,

                           parameterTypes: {

                               "OpportunityId": {

                                   "typeName": "Edm.String",

                                   "structuralProperty": 1 // Primitive Type

                               },

                               "Lob": {

                                   "typeName": "Edm.String",

                                   "structuralProperty": 1 // Primitive Type

                               },

                               "ShowFinalAwardedRoleSelection": {

                                   "typeName": "Edm.String",

                                   "structuralProperty": 1 // Primitive Type

                               },

                               "HasCreditFlag": {

                                   "typeName": "Edm.String",

                                   "structuralProperty": 1 // Primitive Type

                               },

                               "IsMnpOpp": {

                                   "typeName": "Edm.String",

                                   "structuralProperty": 1 // Primitive Type

                               },

                               "ApplicationDate": {

                                   "typeName": "Edm.String",

                                   "structuralProperty": 1 // Primitive Type

                               },

                               "IsLoanMod": {

                                   "typeName": "Edm.String",

                                   "structuralProperty": 1 // Primitive Type

                               },

                               "IsLoanOrig": {

                                   "typeName": "Edm.String",

                                   "structuralProperty": 1 // Primitive Type

                               },

                           },

                           operationName: action  //this is the action name that is wfrv_GetOpportunity

                       };

                   };

               };

               var request = new getOpportunity(action, parameters);

               Xrm.WebApi.online.execute(request).then(

                   function (result) {

                       if (result.ok) {

                           result.json().then(function (response) {

                               if (response.OpportunityModel) {

                                   opportunityModelReceived = JSON.parse(response.OpportunityModel);

                               }

                           });

                       }

                   },

                   function (error) {

                       consol.log(error.message);

                   }

               );

  • Dynamics _365_ CRM Profile Picture
    5 on at

    Hi Andrew,

    Please find screenshot of action.5305.customAction.PNG

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I don't see any issues here. I believe that you have the plugin that handles the message on the backend. Can you please provide the code of the plugin?

  • Scosec Profile Picture
    95 on at

    You could check your network inspector within your browser and find the XHR request an find any error in the response.

    Otherwise plugin logging like mentioned earlier.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 98 Most Valuable Professional

#2
11manish Profile Picture

11manish 77 Super User 2026 Season 2

#3
Travis South Profile Picture

Travis South 39

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans