Working with Selection Lists

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

Working with Selection Lists

  • Comments 6
  • Likes
Supposing that there is a requirement that when a Company is of a particular type then when an Opportunity is created for that company there should be one set of options to put into the Oppo_type field.
You can see in the above screen shot of an Opportunity Summary screen that the Company is a 'Prospect' in which case the Opportunity types should be
  • 'Referral' 
  • 'Recruitment' 
  • 'License' 
But if the Company type is 'Customer' then the Opportunity types should be
  • 'Software' 
  • 'Services' 
  • 'Mixed' 
I could start with a single long list of Options like in the image below.
I could test to see what company type it was and then remove the unwanted options for example:

The code here would be placed in the onCreate script box of the oppo_type field in the OpportunityDetailBox screen.

[code language="javascript"]
if (CRM.GetContextInfo("Company","comp_type")=="Prospect")
{
RemoveLookup("Software");
RemoveLookup("Services");
RemoveLookup("Mixed");
}
[/code]

But this could get unwieldy if there are a lot of options.

Instead, I can create a new sets of options in translations (custom_captions) and then 'swop' the new selection list into the field using the create script

[code language="javascript"]
if (CRM.GetContextInfo("Company","comp_type")=="Partner")
{
LookupFamily = "newoppo_type"
}
[/code]

The hard work is the entry of the different Options allowed for the different Company types but the code becomes much simpler.
Comments
  • The above code is not working for me... Anyother code plzz?

  • Tejaswini what is the error you are getting? the code works without problems. I hope you have the relevant lookup values in your Selection list.

  • In new quote screen, i have created pricinglist drop down box and indent drop down. pricinglist values are partner, testing, default and wholesale. Indent  values are a,b,c,d,e,f.  If i select partner, e and f should not be in the list..

    if(eWare.GetContextInfo("Quote","quot_pricinglistid")=="Partner")

    {

    RemoveLookup("e");

    RemoveLookup("f");

    }

    I tried with this code.. If i gave it in onscript change. But still no changes i can see. e and f is still visible. :(

  • This is not clientside code.  This code is for execution within the server in a create script.

    If the fields 'princinglist' and 'indent' are both on the same screen, and you want options available in 'Indent' to change when 'pricinglist' changes then you can use a technique similar to

    community.sagecrm.com/.../dynamic-selection-lists.aspx

    But you should also look at this article for a codeless way of doing it.

    community.sagecrm.com/.../use-advanced-search-selects-to-created-linked-selection-lists.aspx

  • Do you know if RemoveLookUp() works inside the create script on the rules of a workflow?  We are having Syntax Errors

    Version 6.2

  • It should work fine.  I have just tested it with Sage CRM v7.1 SP2 in an opportunity workflow and there were no problems.

    e.g. for oppo_source

    RemoveLookup("Web");