hi @NageswaraRaoAddanki60 ,
Code has to be implemented in the ValidFor
  Field fieldselecting event.
Here is the sample code to load details dynamically.
  protected virtual void SetUp_WarehouseMonitored_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
       {
           SetUp row = e.Row as SetUp;
           if (row != null)
           {
               var allowedValues = new List<string>();
               var allowedLabels = new List<string>();
               foreach (INSite site in PXSelect<INSite, Where<INSite.siteID, IsNotNull, And<INSite.siteID, NotEqual<SiteAttribute.transitSiteID>, And<Match<Current<AccessInfo.userName>>>>>>.Select(this))
               {
                   allowedValues.Add(site.SiteID.ToString());
                   allowedLabels.Add(site.SiteCD.Trim());
               }
               e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 500, true, typeof(SetUp.warehouseMonitored).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedLabels.ToArray(), false, null);             Â
           }
       }
Hi @NageswaraRaoAddanki60Â
Hope you are looking for the below solution
If I'm understanding correctly, you 2 dropdown fields, and when you change 1st DropDown value, and based on that you wanted to load the 2nd DropDown values.
 DropDown1
 DropDown2
protected virtual void DAC1_DropDown1_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
DAC1 row = e.Row as DAC1;
if (row != null)
{
var allowedValues = new List<string>();
var allowedLabels = new List<string>();
foreach (INSite site in PXSelect<INSite, Where<INSite.siteID, IsNotNull, And<INSite.siteID, NotEqual<SiteAttribute.transitSiteID>, And<Match<Current<AccessInfo.userName>>>>>>.Select(this))
{
allowedValues.Add(site.SiteID.ToString());
allowedLabels.Add(site.SiteCD.Trim());
}
e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 500, true, typeof(DAC1.DropDown1).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedLabels.ToArray(), false, null);
}
}
Â
      // In the Below field selecting you need to add a condition load the values based on the 1st dropdown
Â
protected virtual void DAC1_DropDown2_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
DAC1 row = e.Row as DAC1;
if (row != null)
{
var allowedValues = new List<string>();
var allowedLabels = new List<string>();
foreach (INSite site in PXSelect<INSite, Where<INSite.siteID, IsNotNull, And<INSite.siteID, NotEqual<SiteAttribute.transitSiteID>,
And<Match<Current<AccessInfo.userName>>,
And<Insite.Field1,Equal<Required<Insite.Field1>>>>>>>.Select(this, row.DropDown1))
{
allowedValues.Add(site.SiteID.ToString());
allowedLabels.Add(site.SiteCD.Trim());
}
e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 500, true, typeof(DAC1.DropDown2).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedLabels.ToArray(), false, null);
}
}
Also add one more EVENT to invoke the 2nd Dropdown fieldSelecting event when we change the 1st dropdown
Â
protected virtual void DAC1_DropDown1_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
DAC1 row = e.Row as DAC1;
if (row != null)
{
ref Val = row.Dropdown1;
//The below code will invoke the 2nd DropDown field selecting event to load the values based on the 1st DropDown1
sender.RaiseFieldSelecting<SOLine.shipDate>(row, ref Validate, true);
}
}
Â
Â
Hi @praveenpo , @Naveen Boga In this way I tried. but, couldn't get.Â
here dropdown 1 values are fixed , no need to change the these value.
Â
 protected virtual void SSPSetupActive_ValidFor_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
    {
      SSPSetupActive row = e.Row as SSPSetupActive;
      var allowedValues = new List<string>();
      var allowedLabels = new List<string>();
      if (row != null)
      {
        if (row.Feature == "Inspect")
        {
          allowedValues.Add(SSS.SSP.Helper.Constant.ServiceOrder.ToString());
          allowedLabels.Add(SSS.SSP.Helper.Messages.ServiceOrder.Trim());
        }
        e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 500, false, typeof(SSPSetupActive.validFor).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedLabels.ToArray(), false, null);
      }
    }
Â
Thank you for your support.
Â
Does ValidFor
 field has commit changes in aspx?
Â
Â
Does ValidFor
 field has commit changes in aspx?
Â
Â
Yes, @praveenpo ValidFor field commitchanges=true
<px:PXGridColumn  Type="DropDownList" CommitChanges="True" DataField="ValidFor" Width="70" ></px:PXGridColumn>
I must be missing something somewhere, but from what I can see from your original code, ‘ValidFor’ has a max length of 5. Why the result of field selecting should return 500 I’m not understanding. Also, both ‘combo’ fields are set as keys - (IsKey = true) - which leads me to believe it should be set as a key in the return state, but I could be wrong.
Interpreting the intellisense in Visual Studio, I believe this line:
e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 500, false, typeof(SSPSetupActive.validFor).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedLabels.ToArray(), false, null);
should be:
e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 5, true, typeof(SSPSetupActive.validFor).Name, true, -1, string.Empty, allowedValues.ToArray(), allowedLabels.ToArray(), false, null);
with the ‘-1’ possibly being something else as well, since it is ‘required’ in your code, if that is what this field is for.
This may not fix the problem, but I think it’s always good to understand what your code is doing, and if I’m wrong, then I’ll have learned something new today.
Â
Hi @NageswaraRaoAddanki60Â Are you having these fields in the FORM OR GRID?
If it is in GRID, please also add MatrixMode= true in the .aspx page.
Hi @Naveen Boga , @darylbowman , @praveenpoÂ
Thank you guys for supporting me. I achieved Â
below I added these code
 PXStringListAttribute.SetList<SSPSetupActive.validFor>(cache, row, new stringw] { SSS.SSP.Helper.Constant.ServiceOrder }, new stringw] { SSS.SSP.Helper.Messages.ServiceOrder });
ValidFor Field MatrixMode=true;
Grid SyncPosition=false;
Â
Â
@NageswaraRaoAddanki60Â Awesome Thanks for sharing the update.
Please keep attributes like below.
MatrixMode = true
SyncPosition = true
Â