Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Answered

Retrieve Account Id from a Workflow

Posted on by

Hi,

I have created a workflow where I want to retrieve the newly created id from the account entity.

I was trying to avoid doing this with a plugin and instead wanted to create a really simply workflow that takes the id of record that was just created or updated and adds a record to another entity.

So... account is created, the id is captured and sent be second entity.

However, I don't seem to be able to find the "id" field anywhere in the list... I have tried a few of the other options and have found none that provide the value I want.

Is this not possible with workflows?

Thanks - Greg

Categories:
  • Greggomatic Profile Picture
    Greggomatic on at
    RE: Retrieve Account Id from a Workflow

    Thanks Guido - this is where I was heading - thanks for the confirmation.

  • Verified answer
    Guido Preite Profile Picture
    Guido Preite 54,061 Moderator on at
    RE: Retrieve Account Id from a Workflow

    you need a custom workflow activity for that, but it's very simple

    here a tutorial for starting msdn.microsoft.com/.../gg334455.aspx

    you will need an inputparameter as entityreference

    an output parameter as string

    and inside the execute method you just need to read the id property of the entityreference and set to the output parameter

    something like

    public sealed class GetRecordId : CodeActivity
       {
           [Required]
           [Input("Account")]
           [ReferenceTarget("account")]
           public InArgument<EntityReference> Account { get; set; }
    
           [Output("Account Id")]
           public OutArgument<string> AccountId { get; set; }
           protected override void Execute(CodeActivityContext executionContext)
           {
               EntityReference accountRef = Account.Get<EntityReference>(executionContext);
               AccountId.Set(executionContext, accountRef.Id.ToString());
           }
       }


  • Greggomatic Profile Picture
    Greggomatic on at
    RE: Retrieve Account Id from a Workflow

    Hi Guido - yes, I just want the Id as string (guid format).

    Is this possible or do I need to go down the path of creating a custom workflow activity.

  • Suggested answer
    Guido Preite Profile Picture
    Guido Preite 54,061 Moderator on at
    RE: Retrieve Account Id from a Workflow

    Hi Greg,

    I suppose you will need the Id as a string? because if you need to set as a lookup you can assign it in the process designer to a field that accept the contact lookup

    if you need the id as string an alternative you can create a custom workflow activity

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,263 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,112 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans