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)

Get Output Parameter Of Custom Action in C#

(0) ShareShare
ReportReport
Posted on by

Hey Guys,

Quick coding question:


Currently I'm working with Custom Actions in C#.

I'm able to start my custom action which will create an Invoice from a account.

But I'd like to get that invoice in my code...

I'm starting the "WorkFlow" with

ExecuteWorkflowResponse xOrganizationResponse = (ExecuteWorkflowResponse)orgSvcContext.Execute(request)


But than the xOrganizationResponse just has 1 attribute which is GUID Empty..

Does anyone knows how to get the Output parameter specified in the custom action?

Here's a screenshot of my custom action:

*This post is locked for comments

I have the same question (0)
  • Mahendar Pal Profile Picture
    45,095 on at

    Hi,

    After adding create step in your process, you can use assign step to set your out put parameter, so for example, I have one output parameter called Result of type entityreference, and I have added a step to create account, after that I am using assign step to set my output parameter with previous create step

    Also check this post: http://mkonrad.blogspot.in/2013/09/crm-2013-create-custom-actions.html

    if you want to retrieve your output parameter through code after assignment. 

  • Community Member Profile Picture
    on at

    Hi Mahendar Pal

    As you can see, I'm doing exactly this in my custom action (see picture)

    On german its wert zuweisen = "Assign Value"

    But than how do I get the Value in Code after doing the ExecuteWorkflowRespond xResponde = (ExecuteWorkflowResponde)service.Execute(request)

    ?

  • Mithilesh Kumar Profile Picture
    10,047 on at

    Hi Luca,

    When you call the Action from C# Code you get the Response. Form the Response you can get your Output value.

    For example, if your Action is "new_CustomAction", with "new_outputVal" as Output parameter.

    You need to call the Action and get the output value as below

    new_CutomActionRequest request = new new_CustomActionRequest()

    {

    Target = EntityReference("<your entity for action>", entityid)

    };

    new_CustomActionResponse response = service.Execute(request) as new_CustomActionResponse

    using response from above code you can get the Output of Action.

    Note: I am using Early Bound classes. Generate them from CrmSvcUtil.exe for you Actions

    Hope that helps

    Thanks

  • Mahendar Pal Profile Picture
    45,095 on at

    Hi Luca,

    It seems you did not check the reference blog, Please check the blog and check last section over there it is showing how to get output parameter through code.

  • Community Member Profile Picture
    on at

    Hi Mithilesh Kumar ,

    Thanks for your input. You see that I already have new_invoice (as entityreference) as output value in my custom action. When I use the response after doing exaclty the same function (execute(request) as ExecuteWorkflowRespone) than I get an empty response.. BUT the custom action has already bin triggered...

    Note I'm using latebound..

    Mahendar Pal  I've read the blog entry but it doesn't shows the code on how to get the output parameter, only that he already got it..

  • Mahendar Pal Profile Picture
    45,095 on at

    Hi Luca,

    Please use below code to get your output parameter

       Guid entityid = ((EntityReference)Respons.Results["OutPutParameterName"]).Id;

  • Community Member Profile Picture
    on at

    Hi Mahendar Pal ,

    Thanks for your answer, that's exactly how I would do it.. But my problem is still that the RESPONSE is empty. So I don't have any attributes there.. but the workflow is triggered..

    How can this be? As I already mentioned I'm using latebound (with OrganizationalRequest / Respone and I'm doing OrganizationService.Execute(Request) method to start the workflow. Tell how do I get a Response with Values and not everytime with id = empty(guid)

  • Mahendar Pal Profile Picture
    45,095 on at

    Hello,

    I tried to create a sample action and calling it from my console application, I am able to get response.

    OrganizationResponse Respons = service.Execute(Req);
    Guid responseid = ((EntityReference)Respons.Results["Accountid"]).Id;

  • Community Member Profile Picture
    on at

    Could I see your OrganizationRequest, what are you doing there??

    It can't be that only I'm getting an empty result

  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at

    Off-course, here is my complete request

    OrganizationRequest Req = new OrganizationRequest("new_actiondemo");

     Req["accountname"] ="Customaction"; //input parameter

     Req["Target"] = new EntityReference("account", new Guid("8F029291-F0B9-E411-80DB-C4346BADB590"));  //setting target which is required

                   OrganizationResponse Respons = service.Execute(Req);

                   Guid responseid = ((EntityReference)Respons.Results["Accountid"]).Id;

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