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)

Create link to the new entity record

(0) ShareShare
ReportReport
Posted on by

I have a custom workflow activity that creates new opportunity from my custom workflow activity.
I have that activity as an action step. I am using action, because it has an output. I need to get Id of opportunity i created.
I call that action from JS web resource using Process.js. After that I use Notify.js to notify the user that opportunity was created. On that notification i need to have button that would be link to the newly created opportunity.

Here are some parts of the C# code related to the output parameter. Just to notice that part of the code for creating opportunity, and doing some more tasks works fine:

//define variable
[Output("Opportunity")]
[ReferenceTarget("opportunity")]
public OutArgument<EntityReference> NewOpportunity { get; set; }

//create opportunity and entity reference(i am not sure do ineed entity reference, or something else for that link)
Guid opportunityId = service.Create(opportunity);
EntityReference OppId = new EntityReference(opportunity.LogicalName, opportunityId);

//assign value to the output variable
NewOpportunity.Set(Econtext, OppId);


Here is how i created my action parameter in action definition:
8372.Output.PNG

And here is the JS code where action is called:

function toOpportunity(){

Process.callAction("ad_opportunity",
[{
key: "Target",
type: Process.Type.EntityReference,
value: { id: Xrm.Page.data.entity.getId(), entityType: "ad_productsamplerequest" }
}],
function (param) {
//Success
Notify.add("New Opportunity was created:", "INFO", "opportunity",
[{
type: "button",
text: "Go to opportunity",
callback: function () {

}
}]);
},
function () {
// Error
alert("Opportunity was not created");
}
);

Just to say, it works, action is called, opportunity is created, there is notification after that. just don't know how to use action output parameter to set the link to the opportunity.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Clem Profile Picture
    2,541 on at

    Hi,

    I can see that you are retrieving the GUID of the new created opportunity from your workflow. So with the var "NewOpportunity" you populate you can "manually" generate the link to the new record, ex :

    yourorg.crm.dynamics.com/main.aspx;extraqs=%3fetc%3d3%26id%3d{GUID HERE}&pagetype=entityrecord

    Regards,

    Clément

  • Suggested answer
    Community Member Profile Picture
    on at

    You can try using the direct launching of CRM form using the URi format:

    http://orgurl/main.aspx?etn={entityName}&pagetype=entityrecord&id={GUID}

    Ref: msdn.microsoft.com/.../gg328483.aspx

  • Community Member Profile Picture
    on at

    Hi, is there a problem because I have Code Activity? Is it possible to get the output this way?

    Am i supposed to use Plugin instead, or there is no difference?

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