Skip to main content

Hello,

I got question on how to set checkbox value for a custom field in gridview on Sales Order screen? Here is my DAC

public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{

[PXBool]
[PXUIField(DisplayName= "Is Restricted")]
public virtual bool? UsrIsRestrictedField { get; set; }
public abstract class usrIsRestrictedField : PX.Data.BQL.BqlString.Field<usrIsRestrictedField> { }

}

and here is my graph extension

 

public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{


#region Event Handlers
protected void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{

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

}

}
}

in Customization Studio I set chebox like

and here is how my grid looks:

The problem “IsRestricted” checkbox is never set to checked  

Hi @hotdok 

We should avoid setting any values in the RowSelected event, as its primary purpose is to control the enabling, disabling, visibility, or invisibility of fields.

Could you clarify when exactly you need to check the "Is Restricted" checkbox as part of your functionality? Are you looking to have this checked by default, or is there a specific logic or condition you'd like to apply?


Hi @Naveen Boga 

Thanks for reply. I just want to figure out how can I set checkbox as checked in gridview based on some complex bql request from several DACs.


@hotdok  

You've defined an unbound field (i.e., not a database field). Please note that even if you set a value and refresh the screen, the value will be cleared.

If you want to set a value and have it persist in the database, you'll need to create a database field as shown below.

 

 public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{

PXDBBool]
PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
PXUIField(DisplayName = "Is Restricted")]
public virtual bool? UsrIsRestrictedField { get; set; }
public abstract class usrIsRestrictedField : PX.Data.BQL.BqlBool.Field<usrIsRestrictedField> { }

}

 

Use below logic to update the field

 


ClaLimitInv.SOLineExt itemExt = row.GetExtension<ClaLimitInv.SOLineExt>();
itemExt.UsrIsRestrictedField = true;
Base.Transaction.Cache.Update(row);

 


@Naveen Boga Thanks. Could you please suggest which event to use to update the field?


@hotdok Can you please let me know when exactly you wanted to set this value as TRUE?

Like After entering the Inventory ID, you wanted to check some condition and set the value as TRUE or while saving the Order?


I want to set it on page load at first. So once  the exact sales order is open this calculation should happen. I do not want to save checkbox state in db.


@hotdok  If you do not want to save the field value in the database then you can go ahead with Unbound field and you can set the default value as TRUE in the DAC itself like below. 

Hope this code helps you.

 

public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{

PXBool] // This is Unbound field
PXDefault(true, PersistingCheck = PXPersistingCheck.Nothing)] // Setting the Default Value as TRUE
PXUIField(DisplayName = "Is Restricted")]
public virtual bool? UsrIsRestrictedField { get; set; }
public abstract class usrIsRestrictedField : PX.Data.BQL.BqlBool.Field<usrIsRestrictedField> { }

}

 


no I want to set checbox state based on complex BQL query when screen is opened. So Im trying to understand what event to use for it. I tried to use [PXFormula] attribute for it but it works only with current DAC but I need selecting data from 2 DACs to determine if checkbox should be set or not. I wanted to populate checkbox in RowSelected event handler but it didnt work for me. Moreover it highly not recommended to do. I have BQL request like

[PXFormula(typeof(Exists<Select<ClaLimitInv, Where<ClaLimitInv.inventoryID, Equal<SOLine.inventoryID.FromCurrent>, 
And<ClaLimitInv.orderSourceID, Equal<PX.Objects.SO.SOOrder.orderNbr.FromCurrent>>>>>))]

in realty it will be even more complex adding 2 more DACs with joining.


Now Im trying to implement at least checkbox setting by inventory update - doesn’t work as well

public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{

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;

}

}
}

please suggest how to implement


Hi @hotdok were you able to find a solution? Thank you!


...Im trying to understand what event to use for it…

Have you tried ePXDBScalar]?

 


Reply