Agent Desktop

Get Involved. Join the Conversation.

Topic

    Mohana Gopal Selvam
    Dependent Menu in Agent DesktopAnswered
    Topic posted November 20, 2014 by Mohana Gopal SelvamSilver Crown: 22,500+ Points 
    369 Views, 15 Comments
    Title:
    Dependent Menu in Agent Desktop
    Content:

    Hi Gurus,

    How to create the dependent custom menus (Drop down) in AD. 

    Ex: State drop down values need to set based on Country Drop down

    Thanks,

    Mohan

    Best Comment

    Bhagwan Singh Mer

    For Country-State setup, you can configure it in application (see attached). If it is custom specific, I would suggest that you create a workspace add-ins for same

    .

    Comment

     

    • Bipin Mittal

      Hi Mohana,

      Are you creating two custom fields 'Country' and 'State' or you want to use the fields of the Address field?

      Thanks,

      Bipin

    • Mohana Gopal Selvam

      Hi Bipin,

      I created custom fields only. For your understanding I mentioned State and Country.

      Thanks,

      Mohan

    • Bipin Mittal

      Hi Mohan,

      In that case, you can add both those fields in a workspace and create a Workspace Rule to achieve the same.

      Trigger: On editor load

      Condition : A field has a certain value : Select the value of the 1st custom field based on which you want the values of second custom field

      Then Action : Set menu field to include/exclude menu items : check/Uncheck all the values based on the value of 1st custom field.

       

      The only problem here is that you need to write as many rules as you have values in the 1st custom field.

      Hope, this helps.

      Thanks.

      Bipin 

    • Mohana Gopal Selvam

      Thanks Bipin.

      But for my Scenario we have 150 LOVs in parent drop down. Is there any other workaround?

       

    • Bhagwan Singh Mer

      For Country-State setup, you can configure it in application (see attached). If it is custom specific, I would suggest that you create a workspace add-ins for same

      .

    • Mohana Gopal Selvam

      Thanks MB. I will try with Add-Ins.

    • Maheep Kaur

      Hi Mohana,

      Were you able to achieve this through Addins?

      I have a similar requirement(Dependent Menus)

    • Mohana Gopal Selvam

      Yes we can. For this we have created one custom object and one add-in. Please find the code for your reference. 

      Following is the code:
       if (ActionName.Equals("Bind_Origin_Dest"))
                  {
                      IGenericObject flight = (IGenericObject)_recordContext.GetWorkspaceRecord("kk_flight$FlightDet") as IGenericObject;
                      Int32 id = flight.Id;
                      IList<IGenericField> fields = flight.GenericFields;
                      //String queryString = "SELECT Flight_Number.Name from kk_flight.FlightDet where ID=" + id;
                      string flightNo = string.Empty;
                      foreach (IGenericField eachField in fields)
                      {
                          if (eachField.Name.Equals("Flight_Number"))
                          {
                              flightNo = Convert.ToString(eachField.DataValue.Value);
                              break;
                          }
                      }
                      if (!string.IsNullOrEmpty(flightNo))
                      {
                          String queryString = "SELECT Orig,Dest from Airline.Flight_Routes where Flight_Number=" + flightNo;
       
                          byte[] rawResult = null;
       
                          /*
                           Retrieve the values from the QueryCSV returned values.
                           */
                          RightNowSyncPortClient _client = null;
                          EndpointAddress endPointAddr = new EndpointAddress("https://sitename/cgi-bin/myinterface.cfg/services/soap");
                          BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
                          binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                          binding.MaxReceivedMessageSize = 1024 * 1024;
                          binding.MaxBufferSize = 1024 * 1024;
                          // RightNowSyncPortClient _client = new RightNowSyncPortClient(binding, endPointAddr);
                          _client = new RightNowSyncPortClient(binding, endPointAddr);
       
                          _client.ClientCredentials.UserName.UserName = "UserName";
                          _client.ClientCredentials.UserName.Password = "PWD";
       
                          BindingElementCollection elements = _client.Endpoint.Binding.CreateBindingElements();
                          elements.Find<SecurityBindingElement>().IncludeTimestamp = false;
                          _client.Endpoint.Binding = new CustomBinding(elements);
                          ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
                          clientInfoHeader.AppID = "Basic Create";
       
                          CSVTableSet queryCSV = _client.QueryCSV(clientInfoHeader, queryString, 10000, ",", false, true, out rawResult);
                          CSVTable[] csvTables = queryCSV.CSVTables;
                          if (csvTables!=null && csvTables.Count()>0)
                          {
                              //var result = new Array();
                              DataTable dtOrigin = new DataTable();
                              DataTable dtDestn = new DataTable();
                              dtOrigin.Columns.Add("Origin");
                              dtDestn.Columns.Add("Destination");
                              foreach (string item in csvTables[0].Rows)
                              {
                                  string[] result = item.Split(',');
                                  DataRow rowOrigin = dtOrigin.NewRow();
                                  rowOrigin[0] = result[0];
                                  dtOrigin.Rows.Add(rowOrigin);
       
                                  DataRow rowDestn = dtDestn.NewRow();
                                  rowDestn[0] = result[1];
                                  dtDestn.Rows.Add(rowDestn);
                              }
                              po.PopulateOrigin_Destination(dtOrigin, dtDestn);
                              
                          }
                       
                          
                      }
                  }
    • Suresh Thirukoti

      Thanks for sharing the code mohana...it will help others as this is one of the common requirements in Agent desktop

      ~TSKMJK

    • Maheep Kaur

      Hi Mohana,

      Thanks. That gives an idea on how to achieve this.

      However, Can you elaborate how are you showing these values in "PopulateOrigin_Destination(dtOrigin, dtDestn)" function.

      As in, the origin and destination fields are incident custom fields??

    • Mohana Gopal Selvam

      Yes its a custom fields.

    • Maheep Kaur

      How did you show values in the origin Custom Field?

    • Bhagwan Singh Mer

      Hey RD smiley. Were you able to setup the add-ins code for this?

      Will appreciate if you can provide your CO design and code for this yes

    • Maheep Kaur

      Hi MB,

      Yes I was able to achieve but in a little different way through a workspace addin. I created 2 custom objects. One had the relation between the first level menu and the second level menu. The other which had the 2nd menu's value stored and linked to the incident table.

      On Selecting a value in the first drop down, a pop up comes up displaying the value of the second level dropdown. The agent selects a value and the clicks on save button in the pop up. This creates a custom object entry and shows the 2nd level value in the incident.

      Below is the sample code

      try
                      {
                      int RowCount = 0;
                      IncidentID = incidentid;
                      _RecordContext = _recordContext      
                      NBReasonID = CFvalue;
                 
                    if(NBReasonID!=1813)
                      {

                      queryString = "select NBReasonSub,NBReasonSub.Name from NBReason.NBReasonRelation where Enabled=1 and NBReasonID='" + NBReasonID + "'";
                       byte[] rawResult = null;
                       csvtableset = _client.QueryCSV(clientInfoHeader, queryString, 10, ",", false, true, out rawResult);
                     
                          if (csvtableset == null || csvtableset.CSVTables == null || csvtableset.CSVTables[0].Rows == null || csvtableset.CSVTables[0].Rows.Count() <= 0)
                       {
                           return;
                       }
                      DataTable queryDetails = ConvertCSVToDataTable(csvtableset);

                       RowCount = queryDetails.Rows.Count;

                       if (RowCount != 0)
                       {
                           radioButtons = new System.Windows.Forms.RadioButton[RowCount];
                           for (int i = 0; i < RowCount; i++)
                           {
                               radioButtons[i] = new RadioButton();
                               radioButtons[i].Text = queryDetails.Rows[i][1].ToString();
                               radioButtons[i].Name = queryDetails.Rows[i][0].ToString();
                               this.pnlSubcategory.Controls.Add(radioButtons[i]);
                               radioButtons[i].CheckedChanged += new EventHandler(radioButtons_CheckedChanged);
                           }
                           this.ShowDialog();
                       }
                       else
                       {
                           MessageBox.Show("No Sub Category");

                       }
                       }
                  
                   

    • Maheep Kaur

      Hi Mohana,

      Could you please share the code for the function  PopulateOrigin_Destination(dtOrigin, dtDestn);