locked
how to set a 2nd level subject tree to force select RRS feed

  • Question

  • Hello,

    Does anyone have an idea as to how can i make sure that the customer selects the 2nd Level subject tree value by force. For example if the subject tree 1st level is Password, and the 2nd Level values are 1. Password: Create, 2. Password: Reset. the customer is to be forced to select either of the two. not the 1st Level subject tree value.

    If that can be done, please assist

    Thanks :-)

    Tuesday, July 27, 2010 7:46 AM

Answers

  • you can use AJAX to retrieve the selected subject during the onchnage event of the Subject field and check if it has a parent subject, if it doesn't then show an alert and then clear the subject field. http://msdn.microsoft.com/en-us/library/cc677076.aspx


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Tuesday, July 27, 2010 9:47 AM
    Moderator
  • if your subject tree has 2 level you can do it simply, write fetchxml query, control if the subject "selected" has parent subject, if it has paren, it is

    second level if it has not it is parent, but if subject has more than 2 level you can not cath if it is second.

     

     

     

     

    <fetch mapping=\"logical\" count=\"50\" version=\"1.0\"><entity name=\"subject\"><filter><condition attribute=\"parentsubject\" operator=\"not-null\" /></filter></entity></fetch>";

    • Marked as answer by Jim Glass Jr Thursday, July 29, 2010 7:09 PM
    Tuesday, July 27, 2010 10:44 AM
  • Hi xtzee

    Not at all,

    if you not familiar fetch you can use the function and the script below .

     

    function GetAttributeValueFromID(sEntityName, sGUID, sAttributeName, sID) 

        var xml = "" + 
        "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + 
        "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + 
        GenerateAuthenticationHeader() + 
        "  <soap:Body>" + 
        "    <RetrieveMultiple xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
        "      <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\">" + 
        "        <q1:EntityName>"+sEntityName+"</q1:EntityName>" + 
        "        <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" + 
        "          <q1:Attributes>" + 
        "            <q1:Attribute>"+sAttributeName+"</q1:Attribute>" + 
        "          </q1:Attributes>" + 
        "        </q1:ColumnSet>" + 
        "        <q1:Distinct>false</q1:Distinct>" + 
        "        <q1:PageInfo>" + 
        "          <q1:PageNumber>1</q1:PageNumber>" + 
        "          <q1:Count>1</q1:Count>" + 
        "        </q1:PageInfo>" + 
        "        <q1:Criteria>" + 
        "          <q1:FilterOperator>And</q1:FilterOperator>" + 
        "          <q1:Conditions>" + 
        "            <q1:Condition>" + 
        "              <q1:AttributeName>"+sID+"</q1:AttributeName>" + 
        "              <q1:Operator>Equal</q1:Operator>" + 
        "              <q1:Values>" + 
        "                <q1:Value xsi:type=\"xsd:string\">"+sGUID+"</q1:Value>" + 
        "              </q1:Values>" + 
        "            </q1:Condition>" + 
        "          </q1:Conditions>" + 
        "        </q1:Criteria>" + 
        "      </query>" + 
        "    </RetrieveMultiple>" + 
        "  </soap:Body>" + 
        "</soap:Envelope>" + 
        ""; 
     
        var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); 
     
        xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); 
        xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple"); 
        xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); 
        xmlHttpRequest.setRequestHeader("Content-Length", xml.length); 
        xmlHttpRequest.send(xml); 
     
        // retrieve response and find attribute value 
        var result = xmlHttpRequest.responseXML.selectSingleNode("//q1:" + sAttributeName); 
        if (result == null) 
            return ""; 
        else 
            return result.text; 
    }



    id=crmForm.all.subjectid.DataValue[0].id;
    name=GetAttributeValueFromID("subject",id, "parentsubject", "subjectid");

    if(name>"0")
    alert("it has parent");
    else
    {
    alert("it has not parent");
    crmForm.all.subjectid.DataValue=null;
    }

    • Marked as answer by XoliswaM Friday, July 30, 2010 8:36 AM
    Thursday, July 29, 2010 3:18 PM

All replies

  • you can use AJAX to retrieve the selected subject during the onchnage event of the Subject field and check if it has a parent subject, if it doesn't then show an alert and then clear the subject field. http://msdn.microsoft.com/en-us/library/cc677076.aspx


    MSCRM Bing'd - http://bingsoft.wordpress.com
    Tuesday, July 27, 2010 9:47 AM
    Moderator
  • if your subject tree has 2 level you can do it simply, write fetchxml query, control if the subject "selected" has parent subject, if it has paren, it is

    second level if it has not it is parent, but if subject has more than 2 level you can not cath if it is second.

     

     

     

     

    <fetch mapping=\"logical\" count=\"50\" version=\"1.0\"><entity name=\"subject\"><filter><condition attribute=\"parentsubject\" operator=\"not-null\" /></filter></entity></fetch>";

    • Marked as answer by Jim Glass Jr Thursday, July 29, 2010 7:09 PM
    Tuesday, July 27, 2010 10:44 AM
  • hi ahmet,

    thank you for your response, am not familia with the fetchxml statements. would you kindly help me with that

    Senario is:

    when selected: check if the <subject> has <parentsubject> if not then
    msg: "please select a child subject tree" set focus back to subject
    else
    leave as <parent subject>

    this xml code witll be placed on the onchange event of the subject field right?

    thank you very much!

    Wednesday, July 28, 2010 9:50 AM
  • Hi xtzee

    Not at all,

    if you not familiar fetch you can use the function and the script below .

     

    function GetAttributeValueFromID(sEntityName, sGUID, sAttributeName, sID) 

        var xml = "" + 
        "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + 
        "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + 
        GenerateAuthenticationHeader() + 
        "  <soap:Body>" + 
        "    <RetrieveMultiple xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
        "      <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\">" + 
        "        <q1:EntityName>"+sEntityName+"</q1:EntityName>" + 
        "        <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" + 
        "          <q1:Attributes>" + 
        "            <q1:Attribute>"+sAttributeName+"</q1:Attribute>" + 
        "          </q1:Attributes>" + 
        "        </q1:ColumnSet>" + 
        "        <q1:Distinct>false</q1:Distinct>" + 
        "        <q1:PageInfo>" + 
        "          <q1:PageNumber>1</q1:PageNumber>" + 
        "          <q1:Count>1</q1:Count>" + 
        "        </q1:PageInfo>" + 
        "        <q1:Criteria>" + 
        "          <q1:FilterOperator>And</q1:FilterOperator>" + 
        "          <q1:Conditions>" + 
        "            <q1:Condition>" + 
        "              <q1:AttributeName>"+sID+"</q1:AttributeName>" + 
        "              <q1:Operator>Equal</q1:Operator>" + 
        "              <q1:Values>" + 
        "                <q1:Value xsi:type=\"xsd:string\">"+sGUID+"</q1:Value>" + 
        "              </q1:Values>" + 
        "            </q1:Condition>" + 
        "          </q1:Conditions>" + 
        "        </q1:Criteria>" + 
        "      </query>" + 
        "    </RetrieveMultiple>" + 
        "  </soap:Body>" + 
        "</soap:Envelope>" + 
        ""; 
     
        var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); 
     
        xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); 
        xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple"); 
        xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); 
        xmlHttpRequest.setRequestHeader("Content-Length", xml.length); 
        xmlHttpRequest.send(xml); 
     
        // retrieve response and find attribute value 
        var result = xmlHttpRequest.responseXML.selectSingleNode("//q1:" + sAttributeName); 
        if (result == null) 
            return ""; 
        else 
            return result.text; 
    }



    id=crmForm.all.subjectid.DataValue[0].id;
    name=GetAttributeValueFromID("subject",id, "parentsubject", "subjectid");

    if(name>"0")
    alert("it has parent");
    else
    {
    alert("it has not parent");
    crmForm.all.subjectid.DataValue=null;
    }

    • Marked as answer by XoliswaM Friday, July 30, 2010 8:36 AM
    Thursday, July 29, 2010 3:18 PM
  • hi ahmet,

    Thank you! it works

     

    Friday, July 30, 2010 8:37 AM