locked
Single Line Text RRS feed

  • Question

  • Hi

     I want condtion based on the text box text value

    example: if (TextName=rammohan)

          i have enable to some control..

     if (Textname=abec)

     i hav enable the some contorol... can you please suggest it how retrive the text based condition..

    i know how to filter based on the Option text box.. but i want normal text box


    Rammohan

    Monday, February 4, 2013 5:57 AM

Answers

  • Hello Rammmohan,

    you can use code like below

    if (Xrm.Page.getAttribute("TxtFieldName").getValue() != null) {
    var _Value = Xrm.Page.getAttribute("TxtFieldName").getValue();
     switch (_Value) {
    case "ABC":
    Xrm.Page.ui.controls.get("FieldName").setDisabled(false);
    break;
    ///rest cases
    }
    }


    Contact Me
    Follow me on Twitter
    My Facebook Page
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Monday, February 4, 2013 6:16 AM
    Moderator

All replies

  • Hello Rammmohan,

    you can use code like below

    if (Xrm.Page.getAttribute("TxtFieldName").getValue() != null) {
    var _Value = Xrm.Page.getAttribute("TxtFieldName").getValue();
     switch (_Value) {
    case "ABC":
    Xrm.Page.ui.controls.get("FieldName").setDisabled(false);
    break;
    ///rest cases
    }
    }


    Contact Me
    Follow me on Twitter
    My Facebook Page
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Monday, February 4, 2013 6:16 AM
    Moderator
  • Hi, Try this code:

    function condition()

    {

    var txt = Xrm.Page.getAttribute("Textbox name").getValue();

    if(txt = "ABC"){

    Xrm.Page.ui.controls.get("Field name").setVisible(true);

    }

    else if(txt ="DEF"){

    Xrm.Page.ui.controls.get("Field name").setVisible(false);

    }

    }


    Naren



    • Edited by Naren MN Monday, February 4, 2013 8:18 AM
    Monday, February 4, 2013 8:17 AM
  • Rammohan if you have few conditional statement you can go for "IF Statement"

    if you more conditional statements you can go for "Switch"statement.


    ms crm

    Monday, February 4, 2013 8:39 AM