Skip to main content

Notifications

Dynamics 365 general forum

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,081 Super User 2024 Season 1 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,081 Super User 2024 Season 1 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

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans