Skip to main content
Answer

Set checkbox state by inventory update

  • August 29, 2024
  • 2 replies
  • 50 views

Forum|alt.badge.img+1

Hi,

Could you please provide code to set checkbox state by inventory update. I created this one but it doesn’t work

protected void SOLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{

var row = (SOLine)e.Row;
if (row != null)
{
ClaLimitInv.SOLineExt itemExt = PXCache<SOLine>.GetExtension<ClaLimitInv.SOLineExt>(row);
itemExt.UsrIsRestrictedField = true;

}

}

my DAC is

public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{
#region IsRestrictedField
[PXBool]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]



public virtual bool? UsrIsRestrictedField { get; set; }
public abstract class usrIsRestrictedField : PX.Data.BQL.BqlString.Field<usrIsRestrictedField> { }
}

 

Best answer by Naveen Boga

@hotdok  I see that you created Unbound field (NOT a database field), so it will not save into the database. Once you refresh the screen, it will clears the value.

 

If you wanted to change to Database field. Below is the code for reference.

 

 protected virtual void SOLine_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e, PXFieldUpdated BaseInvoke)
{
BaseInvoke?.Invoke(sender, e);
SOLine row = (SOLine)e.Row;

if (row != null)
{
ClaLimitInv.SOLineExt itemExt = row.GetExtension<ClaLimitInv.SOLineExt>();
itemExt.UsrIsRestrictedField = true;
}
}

 

DAC:

public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{
#region IsRestrictedField
[PXDBBool]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
public virtual bool? UsrIsRestrictedField { get; set; }
public abstract class usrIsRestrictedField : PX.Data.BQL.BqlBool.Field<usrIsRestrictedField> { }
}

 

2 replies

Sagar Greytrix
Captain II
Forum|alt.badge.img+3

Hi @hotdok 

could you please try below code

protected void SOLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{

var row = (SOLine)e.Row;
if (row != null)
{
cache.SetValue<SOLineExt.UsrIsRestrictedField>(row, true);

}

}


If You cam not find your custom field using SetValue, You can also use SetValueExt.

Hope this works.​​​​​​


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • August 29, 2024

@hotdok  I see that you created Unbound field (NOT a database field), so it will not save into the database. Once you refresh the screen, it will clears the value.

 

If you wanted to change to Database field. Below is the code for reference.

 

 protected virtual void SOLine_InventoryID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e, PXFieldUpdated BaseInvoke)
{
BaseInvoke?.Invoke(sender, e);
SOLine row = (SOLine)e.Row;

if (row != null)
{
ClaLimitInv.SOLineExt itemExt = row.GetExtension<ClaLimitInv.SOLineExt>();
itemExt.UsrIsRestrictedField = true;
}
}

 

DAC:

public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{
#region IsRestrictedField
[PXDBBool]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
public virtual bool? UsrIsRestrictedField { get; set; }
public abstract class usrIsRestrictedField : PX.Data.BQL.BqlBool.Field<usrIsRestrictedField> { }
}