tags:

views:

246

answers:

3

I would like to have a workflow create a task, then email the assigned user that they have a new task and include a link to the newly created task in the body of the email. I have client side code that will correctly create the edit URL, using the entities GUID and stores it in a custom attribute. However, when the task is created from within a workflow, the client script isn't run.

So, I think a plug-in should work, but I can't figure out how to determine the URL of the CRM installation. I'm authoring this in a test environment and definitely don't want to have to change things when I move to production. I'm sure I could use a config file, but seems like the plug-in should be able to figure this out at runtime.

Anyone have any ideas how to access the URL of the crm service from within a plug-in? Any other ideas?

Thanks!

+1  A: 

There is no simple way to do this. However, there is one.

The MSCRM_Config is the deployment database that handle physical deployment properties, like the URL from which users are accessing the CRM deployment. The url that you might want is the one stored in "ADWebApplicationRootDomain", in the MSCRM_CONFIG.dbo.DeploymentProperties table. You may need some permission to access this database.

Note that this doesn't work in a deployment that is an Internet Facing Deployment.

Another way could be to query the discovery service to retrieve the same information (in the case that you are on the Online edition of MSCRM4).

Mercure Integration
To clarify what you're saying, the URL is in the table but only if I'm NOT using IFD? I haven't tried IFD yet, but I thought it added internet facing deployment to an onsite deployment. I.e. both worked. Is this incorrect?
Greg McGuffey
The problem is that if you deploy CRM using IFD, the URL should be http://orgname.dnsprefix.company.com when accessing from the internet. But what will be stored in CRM is http://internalservername and this can't be accessed from the internet...
Mercure Integration
OK, so the internal URL would still work, but the URL wouldn't work for IFD users. That makes (unfortunate) sense. Thanks
Greg McGuffey
+1  A: 

What do you mean by "change things"?

If you create a custom workflow assembly, you can give it a server url input. Once you register it with CRM, you can simply type in the server url when you configure the workflow. You'll have to update the url for any workflows that use the custom workflow assembly once you move to production, but you'll only have to do that once.

My apologies if this is what you meant you wanted to avoid.

Edit: Sounds like you may be able to use the CustomConfiguration attribute when you register the plugin. Here's some more info.

http://blogs.msdn.com/crm/archive/2008/10/24/storing-configuration-data-for-microsoft-dynamics-crm-plug-ins.aspx

Polshgiant
This is good to know, but I was using a plug-in, not a custom workflow activity. I need to be able to insert a URL into the body of an email (sendemailactivity) that is a link to a specific entity.
Greg McGuffey
A: 

String Url = ((string)(Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\MSCRM").GetValue("ServerUrl"))).Replace("MSCRMServices", "");

DarkAxe