Question : Alternative to CRM plug-in? Assistance with CRM Plug-in?

Hi,

I am attempting to restrict the price lists shown when adding a product to a price list. Specifically,  when I open a Product, select Price List Items and click Add Price List Item, it should only show Price Lists that are in the User's business unit

(Note: I know that Price Lists exist at the organizational level, not the business unit level, see below for workaround)

My approach, so far, has been to capture the businesssunitidname using an onLoad event that makes xml calls to CRM Web services. This onLoad event (for Product) then populates a number of custom fields on Product including the businessunitidname for the logged in user.

Since the businessunitidname is the same as the Price List name, what I am trying to do is to match these, so that only Price Lists with a name that matches the businessunitidname are returned when I attempt to add a Product to a Price List.

To match the Price List name and businessunitidname shown on the Product form, it has been suggested that I create a custom entity that provides the mapping and then "register a plugin on RetrieveMultiple and debug the code to see whether you are getting the results or not. Once you have the result set, filter that result set based on your conditions".

I have been working on the plug-in suggested above (by a very experienced CRM developer/expert) and I am not really making any progress.  I have programming experience in VB, SQL database development and Oracle database development. I also have experience with CRM deployment, client side customization, ASP.NET IFRAME development but nothing at this level.

I am looking at what my alternatives are in this situation.  If there is another way to approach this than a plug-in (using client side customizations), then I would be interested in hearing what that might be.

Otherwise, I am looking for coding of the plugin and would gladlly pay for this assistance. Chinmay, if you have time for this level of assistance, please let me know.

Thanks


Answer : Alternative to CRM plug-in? Assistance with CRM Plug-in?

I am SERIOUSLY PISSED!!! I posted a long answer and somehow it didn't submit... GRRR GRRRR GRRRR Stupid Stupid ISPs n STUPID page Implementations.... no way to recover what you have written.. GRRR GRRRR

Now coming to the answer.

Hi apollo7,

Quality of my answer will drop a little now[maybe or maybe not... you know you can never be as good as the first time :(]

Reference link : http://crm.georged.id.au/post/2008/02/16/Filtering-lookup-data-in-CRM-4.aspx

Steps :

1. Take Backup of :

 - C:\Program Files\Microsoft Dynamics CRM\CRMWeb\Products\ProductPriceLevel\edit.aspx
 - C:\Program Files\Microsoft Dynamics CRM\CRMWeb\_controls\lookup\lookupsingle.aspx

2. In  C:\Program Files\Microsoft Dynamics CRM\CRMWeb\Products\ProductPriceLevel\edit.aspx

add first code snippet as shown in the beginning of the function window.onload

3. In  C:\Program Files\Microsoft Dynamics CRM\CRMWeb\_controls\lookup\lookupsingle.aspx

add second code snippet at the end of the file

This one will take some time 'cause we might have to tune it further. But this approach should get us the desired results.

And just so you know this one is a totally unsupported one.

Regards,
Chinmay



1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
C:\Program Files\Microsoft Dynamics CRM\CRMWeb\Products\ProductPriceLevel\edit.aspx
function window.onload()
{
//---------------Price List Hack -------------------
var field = crmForm.all.pricelevelid; 
{ 
    // Ensure that search box is not visible in a lookup dialog
    field.lookupbrowse = 1; 
    
    // Pass fetch xml through search value parameter 
    field.AddParam("search", 
     "<fetch mapping='logical'><entity name='businessunit'>" 
    + "<filter><condition attribute='businessunitid' operator='eq' value='" 
    + crmForm.all.<<the field that holds businessunitid>>
    + "' /></filter></entity></fetch>"); 
}

//---------------Price List Hack -------------------

 C:\Program Files\Microsoft Dynamics CRM\CRMWeb\_controls\lookup\lookupsingle.aspx

<script runat="server"> 

protected override void OnLoad( EventArgs e ) 
{ 
      base.OnLoad(e); 
      crmGrid.PreRender += new EventHandler( crmgrid_PreRender ); 
} 

void crmgrid_PreRender( object sender , EventArgs e ) 
{
    // As we don't want to break any other lookups, ensure that we use workaround only if
    // search parameter set to fetch xml.
    if (crmGrid.Parameters["search"] != null && crmGrid.Parameters["search"].StartsWith("<fetch")) 
    { 
        crmGrid.Parameters.Add("fetchxml", crmGrid.Parameters["search"]);  

        // searchvalue needs to be removed as it's typically set to a wildcard '*' 
        crmGrid.Parameters.Remove("searchvalue");  

        // Icing on a cake - ensure that user cannot create new contact outside of the account
        // and then select it.
        this._showNewButton = false; 
    } 
} 

</script>
Random Solutions  
 
programming4us programming4us