locked
How to visible two purticular fields based on the selection of purticular value of dropdown.? RRS feed

  • Question

  • I have a drop-down field named "Lead Source" in which there are some values like :-  

    Advertisement/Partner/Public Relation/Referrer/Web

    Now the requirement is when anyone select "Referrer" in drop-down then only 2 fields should be visible below :-

    Referrer ID  and  Referrer Name.

    So how i can i do this please answer.

    Thanking you in Advance!

    Tuesday, August 12, 2014 6:48 AM

Answers

  • You should be able to do this through Business Process in CRM.  You can show and hide fields using Process, so what you will do is make your fields, hide them by default and then use Process to show the fields (and if you want, make them mandatory).

    The postings on this site are solely my own and do not represent or constitute Hitachi Solutions' positions, views, strategies or opinions.

    • Marked as answer by Goswami Amit Wednesday, August 20, 2014 11:14 AM
    Thursday, August 14, 2014 5:38 PM
  • You should use Javascript on Change of Lead source
    as

    function show_hide(){
    //get leadsource Option text
    var lead_source=Xrm.Page.getAttribute("CRMFieldName").getSelectedOption().text;
    
    if(lead_source=="Referrer")
    {
    //show the fields visible
    Xrm.Page.getControl("new_referrerid").setVisible(true);
    Xrm.Page.getControl("new_referrername").setVisible(true);
    }
    
    else
    {
    //hide the fields
    Xrm.Page.getControl("new_referrerid").setVisible(false);
    Xrm.Page.getControl("new_referrername").setVisible(false);
    }
    
    
    }


    Muhammad Sohail



    • Edited by sohail450 Friday, August 15, 2014 10:00 AM
    • Marked as answer by Goswami Amit Wednesday, August 20, 2014 11:15 AM
    Friday, August 15, 2014 9:58 AM
  • no this can well run on drop down field(Option set)

    Actually in Drop-down option have text and value both

    like lead source have option text Referrer and value 1

    From dropdown you can get  text or value both

    here i am getting text but you can get value set Condition on value also.


    Muhammad Sohail

    • Marked as answer by Goswami Amit Wednesday, August 20, 2014 12:23 PM
    Wednesday, August 20, 2014 12:09 PM
  • Hi,

    Could you paste the code that you have used.?


    Thanks and Regards.

    • Marked as answer by Goswami Amit Friday, August 22, 2014 5:42 AM
    Thursday, August 21, 2014 1:19 PM

All replies

  • I have a drop-down field named "Lead Source" in which there are some values like :-  

    Advertisement/Partner/Public Relation/Referrer/Web

    Now the requirement is when anyone select "Referrer" in drop-down then only 2 fields should be visible below :-

    Referrer ID  and  Referrer Name.

    So how i can i do this please answer.

    Thanking you in Advance!


    Thursday, August 14, 2014 7:42 AM
  • You should be able to do this through Business Process in CRM.  You can show and hide fields using Process, so what you will do is make your fields, hide them by default and then use Process to show the fields (and if you want, make them mandatory).

    The postings on this site are solely my own and do not represent or constitute Hitachi Solutions' positions, views, strategies or opinions.

    • Marked as answer by Goswami Amit Wednesday, August 20, 2014 11:14 AM
    Thursday, August 14, 2014 5:38 PM
  • You should use Javascript on Change of Lead source
    as

    function show_hide(){
    //get leadsource Option text
    var lead_source=Xrm.Page.getAttribute("CRMFieldName").getSelectedOption().text;
    
    if(lead_source=="Referrer")
    {
    //show the fields visible
    Xrm.Page.getControl("new_referrerid").setVisible(true);
    Xrm.Page.getControl("new_referrername").setVisible(true);
    }
    
    else
    {
    //hide the fields
    Xrm.Page.getControl("new_referrerid").setVisible(false);
    Xrm.Page.getControl("new_referrername").setVisible(false);
    }
    
    
    }


    Muhammad Sohail



    • Edited by sohail450 Friday, August 15, 2014 10:00 AM
    • Marked as answer by Goswami Amit Wednesday, August 20, 2014 11:15 AM
    Friday, August 15, 2014 9:58 AM
  • thanx a lot sir :)
    Wednesday, August 20, 2014 11:15 AM
  • Thank you so much sir

    Wednesday, August 20, 2014 11:16 AM
  • but sir, this is when lead source is a text field not dropdown(option set) ?

    Wednesday, August 20, 2014 11:22 AM
  • but sir i think this is not possible by workflow 
    Wednesday, August 20, 2014 11:24 AM
  • no this can well run on drop down field(Option set)

    Actually in Drop-down option have text and value both

    like lead source have option text Referrer and value 1

    From dropdown you can get  text or value both

    here i am getting text but you can get value set Condition on value also.


    Muhammad Sohail

    • Marked as answer by Goswami Amit Wednesday, August 20, 2014 12:23 PM
    Wednesday, August 20, 2014 12:09 PM
  • ok Sir thanks a lot.

    i'll implement this .

    Wednesday, August 20, 2014 12:24 PM
  • yes but you can do by using Business Rules in CRM Business Rules are for none developer
    I hope you are familiar with Workflow and Business Rule both are different  things

    for example


    Muhammad Sohail


    • Edited by sohail450 Wednesday, August 20, 2014 12:30 PM
    Wednesday, August 20, 2014 12:29 PM
  • Sir i have set your code through Web Resource and then call on change of picklist but the ERROR is coming please see :-
    Wednesday, August 20, 2014 1:06 PM
  • Sir, Now after this ERROR i have made some changes not what happening is "No Response is coming of any type after selecting 'Reference' in picklist "

    Please HELP me Sir ..

    Thursday, August 21, 2014 6:42 AM
  • And the Two Fields that are suppose to come on selection of 'Reference' in picklist 'Referrer ID' and 'Referrer Name'  are hidden by me.

    Please HELP me ..

    Thursday, August 21, 2014 6:44 AM
  • Sir, please Help ..

    See the Screen Shots please.

    Thursday, August 21, 2014 1:04 PM
  • Hi,

    Could you paste the code that you have used.?


    Thanks and Regards.

    • Marked as answer by Goswami Amit Friday, August 22, 2014 5:42 AM
    Thursday, August 21, 2014 1:19 PM
  • See Sir : -

    function show_hide()
    {
    var lead_source=Xrm.Page.getAttribute("new_picklist").getSelectedOption().text;
    if(lead_source=="Reference")
    {
    Xrm.Page.getA("new_referrerid").setVisible(true);
    Xrm.Page.getAttribute("new_referrername").setVisible(true);
    }
    }

    Sir, i have debug separate lines so inside if condition code there is some problem, till if code is working.

    Now see when i select Reference this ERROR is coming : -

    And if i choose other option of picklist there is no response :(

    Please HELP!

    Friday, August 22, 2014 5:29 AM
  • See Sir : -

    function show_hide()
    {
    var lead_source=Xrm.Page.getAttribute("new_picklist").getSelectedOption().text;
    if(lead_source=="Reference")
    {
    Xrm.Page.getA("new_referrerid").setVisible(true);
    Xrm.Page.getAttribute("new_referrername").setVisible(true);
    }
    }

    Sir, i have debug separate lines so inside if condition code there is some problem, till if code is working.

    Now see when i select Reference this ERROR is coming : -

    And if i choose other option of picklist there is no response :(

    Please HELP!


    Friday, August 22, 2014 5:30 AM
  • Hi,

    Issue is with this line. 

    var lead_source=Xrm.Page.getAttribute("new_picklist").getSelectedOption().text;

    It should be 

    var lead_source = Xrm.Page.data.entity.attributes.get("new_picklist").getText();

    OR

    var lead_source = Xrm.Page.getAttribute("new_picklist").getText();



    Thanks and Regards. Mark as answer, if it answers yours question.


    • Edited by Ravitheja J Friday, August 22, 2014 5:42 AM
    Friday, August 22, 2014 5:42 AM
  • Sir, this didn't work Sorry :(

    I have tried both the lines which you write,

    See now the ERROR is (On the selection of Reference): -

    The Code is Now :

    function show_hide()
    {
    var lead_source = Xrm.Page.data.entity.attributes.get("new_picklist").getText();
    if(lead_source=="Reference")
    {
    Xrm.Page.getAttribute("new_referrerid").setVisible(true);
    Xrm.Page.getAttribute("new_referrername").setVisible(true);
    }
    }

    Friday, August 22, 2014 6:17 AM