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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Dynamics 365 9.x How to invoke a custom action from C#

(0) ShareShare
ReportReport
Posted on by 152

Hello everyone,

In previous verions of CRM I have been able to execute successfully actions via C# console application or plugins.  But in this scenario, a Dynamics 365 9.x envionment, I am having an issue and I cannot find any answer about it.

I am using the following code to execute the action:

//Define the action as a OrganizationRequest
var targetAction = new OrganizationRequest("actionlogicalname"); // Action logicalName

//Define Input Parameters.Only mandatory parameters are needed for a successful execution, optional parameters can be added too.
targetAction["Inputparameter1"] = "value1";
targetAction["Inputparameter2"] = "value2";
targetAction["Inputparameter3"] = "value3";
targetAction["Inputparameter4"] = "value4";
Console.WriteLine("Input parameters provided sucessfully");

//Execute the action
OrganizationResponse response = service.Execute(targetAction);
Console.WriteLine("Action executed successfully");
Console.ReadKey();

But by any reason, I am experiencing the following issue on the service.Execute(targetAction):  "System.ServiceModel.FaultException`1: 'Required field 'Name' is missing'"

Does anyone have any insight regarding this issue?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Jorge,

    I don't think there is anything change in the way you call custom action between 8.2 & 9.0.

    Just did a quick try from console and it worked fine. Created a global action which take "Name" (string) as an input parameter and create a task with the subject as the paramter value.

    =================

    using (service = new OrganizationServiceProxy(new Uri(_organizationURI), null, _credential, null))

               {

                   var testCustomAction = new OrganizationRequest()

                   {

                       RequestName = "new_TestCustomAction"

                   };

                   testCustomAction.Parameters.Add("Name", "Ravi");

                   service.Execute(testCustomAction);

               }

    ==================

    8764.customaction.png

    Hope this helps.

  • Verified answer
    Jorge Gomez Profile Picture
    152 on at

    Thanks a lot Ravi,

    It is fixed,  the issue was in the action steps definition, it was execution another action with parameters which were not being provided.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans