Web Resource Naming

I found something quite interesting while working on my CRM Migration Assistant JavaScript conversion tool.

We you create a web resource, you, the developer, are responsible for prepending the name of the web resource with the proper Customization Prefix.

The second rather interesting fact is that CRM doesn’t care what that prefix is. It seems to just look for an underscore character ( "_" ) somewhere in the name.  If it doesn’t find it, it will give you an error.

So, adding a customization prefix is not a real issue, but would it not be much better to retrieve the customization prefix of the solution you are adding the web resource to?  Of course it would.  Here’s how you do it:

Add the following method to your code:

public static string GetCustomizationPrefix(CrmOrganizationServiceContext context, 
                                            Guid solutionId)
    var publisher = from s in context.CreateQuery<Solution>()
                join p in context.CreateQuery<Publisher>() on 
                s.PublisherId.Id equals p.PublisherId.Value
                where s.SolutionId.Value == solutionId
                select new Publisher
                    CustomizationPrefix = p.CustomizationPrefix

    if (publisher != null)
        return publisher.First().CustomizationPrefix;

    return string.Empty;


As you can see, you pass in the CRM Service Context that you have created earlier.  The second parameter is the ID of the Solution that you will be working with.

Here is how it is used:

string customizationPrefix = GetCustomizationPrefix(context, ActiveSolutionId);


string webResourceName = string.Format("{0}_{1}", 

The variable webResourceName will be used as the name when the web resource is created.

Leave a Reply 1 comment