web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to get Organization URL in workflow. (CodeActivity in C#)

(0) ShareShare
ReportReport
Posted on by

Hi there! I have CRM Online instance.

Please could you tell me how to get Organization URL in workflow code?

I have C# based CodeActivity dll. And I need full url of organization. But I can not find solution(

I have variables in my cod:

IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory =
                    executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);


But I have found only OrganizationName and OrganizationId (guid) properties.

*This post is locked for comments

I have the same question (0)
  • abhishek_255 Profile Picture
    1,614 on at
    RE: How to get Organization URL in workflow. (CodeActivity in C#)

    Hi- If you provide an idea why you need organization URL within custom activity would be great?

    In case that is something that needs to be accomplished through custom activity, then you can add an Input parameter of string type in your custom activity and set/hard code it through your workflow.

    Best Regards,

    Abhishek

  • chauhanhardik Profile Picture
    687 on at
    RE: How to get Organization URL in workflow. (CodeActivity in C#)

    Hello LeeSwagger,

    I'm also having the same requirement.

    Do find any solution for the same?

    If yes, then please tell me how it can be achieved.

    Thanks,

    Harry

  • Razim Khan Profile Picture
    150 on at
    RE: How to get Organization URL in workflow. (CodeActivity in C#)

    public static OrganizationService GetCRMService()
    {
    var crConnection = CrmConnection.Parse(@"Url=http://IP address or domain name; Username=username;password=******;");
    return new OrganizationService(crConnection);
    }

    then you can use above connection like this
     var crmService = GetCRMService();

  • Suggested answer
    Sergio Macias Profile Picture
    225 on at
    RE: How to get Organization URL in workflow. (CodeActivity in C#)

    Hi Lee I was playing with the workflow and I found something, if you create a text field on your entity and one step before your code activity call, you can set up the value using the property under the entity you are using, the out of the box field is "Record URL(Dynamic)"

    1. Before your code activity call select the update step on the current record

    2. Look for your new custom field and click on it

    3. From the dropdowns list on the right side of the window select the entity and under the attributes dropdown search for the "Record URL(Dynamic)" and update your custom field

    4. Send this custom field value as a parameter to your code activity and that´s it5543.DynamicURL.JPG

  • Sergio Macias Profile Picture
    225 on at
    RE: How to get Organization URL in workflow. (CodeActivity in C#)

    Here is an idea

    1. You have a workflow that runs under a specific entity

    2. It runs when a record is created,updated or deleted

    3. If you add some javascript code on the load event when user creates the record you can save the client url on a field

    4. You can pass this value to the code activity

    Or am I missing something?

  • Community Member Profile Picture
    on at
    RE: How to get Organization URL in workflow. (CodeActivity in C#)

    It need in workflow only. Workflow does not connect to any entity.

  • Sergio Macias Profile Picture
    225 on at
    RE: How to get Organization URL in workflow. (CodeActivity in C#)

    Hi Lee, ok I understand now what you were saying, one question, do you need it on the code activity or is there a possibility to get the url using javascript and pass it into a hidden field and read it on the workflow

  • Community Member Profile Picture
    on at
    RE: How to get Organization URL in workflow. (CodeActivity in C#)

    I need full address of my Organization.

    For example if I got OrganizationName as xxx

    I don't know full address, it can be:

    xxx.crm1.dynamics.com

    xxx.crm2.dynamics.com

    xxx.crm3.dynamics.com

    ......

    Bad thing that I do not know how to know crmX.dynamics.com part. Which number.

  • Suggested answer
    Sergio Macias Profile Picture
    225 on at
    RE: How to get Organization URL in workflow. (CodeActivity in C#)

    if you vae that information you can build the url you want as CRM has a standard url for services (well in this new crm 365)

    You can build your string for example if you want de API URL

    string _url = "https://"+ OrgName+".api.crm.dynamics.com/api/data/v8.2/"

    Organization Service

    String _url = https://"+OrgName+".api.crm.dynamics.com/XRMServices/2011/Organization.svc"

    In case you have different version for CRM you can check the url strings under Settings/Customizations/Developer Resources

    Please let me know if this is what you were asking for.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans