Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Create link to the new entity record

$
0
0

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:

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.


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>