Hello,
I need to store the value of a checkbox on the Purchase Order Confirmation form. The check box is custom and I have added it to the PurchEditLines form (displayed there).
So I have a field on the PurchParmUpdate table called CreditReference which has an EDT of NoYes and defaults as no. I am trying to send the new value of the checkbox when it is checked to PurchPurchaseOrderHeader.CreditReference. When I run that confirmation, it shows as a ‘0’.
Here are some code snippets that I use to run this.
Event Handler Class:
[PostHandlerFor(classStr(PurchPurchaseOrderDP), methodStr(PurchPurchaseOrderDP, processReport))]
public static void PurchPurchaseOrderDP_Post_processReport(XppPrePostArgs args)
{
VendPurchOrderJour vendPurchOrderJour;
PurchPurchaseOrderDP dpInstance = args.getThis() as PurchPurchaseOrderDP;
PurchPurchaseOrderContract contract = dpInstance.parmDataContract();
PurchTable purchTable;
PurchParmUpdate purchParmUpdate;
VendTable vendTable;
HcmWorker hcmWorker;
HcmEmployeeEntity hcmEmployeeEntity;
PurchPurchaseOrderHeader purchPurchaseOrderHeader = dpInstance.getPurchPurchaseOrderHeader();
vendPurchOrderJour = VendPurchOrderJour::findRecId(dpInstance.parmPurchaseOrderContract().parmRecordId());
//This if statement works as it should and gives me the correct value in Precision Forms
if(vendPurchOrderJour.CostCenterDisplay != "")
{
ttsbegin;
while select forupdate * from purchPurchaseOrderHeader
{
purchPurchaseOrderHeader.CostCenterDisplay = vendPurchOrderJour.CostCenterDisplay;
purchPurchaseOrderHeader.write();
}
ttscommit;
}
//This one will go through the okay as Yes but will go through the
//purchPurchaseOrderHeader as No in Precision Forms
if(purchParmUpdate.CreditReference == 1)
{
ttsbegin;
while select forupdate * from purchPurchaseOrderHeader
{
purchPurchaseOrderHeader.CreditReference = purchParmUpdate.CreditReference;
purchPurchaseOrderHeader.write();
}
ttscommit;
}
}
[FormControlEventHandler(formControlStr(PurchEditLines, PurchParmUpdate_CreditReference), FormControlEventType::Modified)]
public static void PurchParmUpdate_CreditReference_OnModified(FormControl sender, FormControlEventArgs e)
{
PurchParmUpdate purchParmUpdate;
PurchPurchaseOrderHeader purchPurchaseOrderHeader;
FormRun fr = sender.formRun();
FormControlCancelableSuperEventArgs cancelArgs = e as FormControlCancelableSuperEventArgs;
FormCheckBoxControl formCheckboxCredRef = sender as FormCheckBoxControl;
if(formCheckboxCredRef.checked())
{
info("Credit Reference will be printed");
select * from purchPurchaseOrderHeader
join purchParmUpdate
where purchParmUpdate.PurchId_SA == purchPurchaseOrderHeader.PurchId;
purchParmUpdate.CreditReference = enum2int(NoYes::Yes);
}else
{
info("Credit Reference will not be printed");
select * from purchPurchaseOrderHeader
join purchParmUpdate
where purchParmUpdate.PurchId_SA == purchPurchaseOrderHeader.PurchId;
purchParmUpdate.CreditReference = enum2int(NoYes::No);
}
}
[FormControlEventHandler(formControlStr(PurchEditLines, OK), FormControlEventType::Clicked)]
public static void OK_OnClicked(FormControl sender, FormControlEventArgs e)
{
PurchPurchaseOrderHeader purchPurchaseOrderHeader;
PurchParmUpdate purchParmUpdate;
FormRun fr = sender.formRun() as FormRun;
select * from purchPurchaseOrderHeader
join purchParmUpdate
where purchParmUpdate.PurchId_SA == purchPurchaseOrderHeader.PurchId;
info(enum2Str(purchParmUpdate.CreditReference));
info(enum2Str(purchPurchaseOrderHeader.CreditReference));
purchPurchaseOrderHeader.validateWrite();
}
Contract Extension Class:
[ExtensionOf(classStr(PurchPurchaseOrderContract))]
final class PurchPurchaseOrderContract_Extension
{
public CreditReference CreditReference;
[DataContractAttribute('CreditReference')]
public boolean parmCreditReference(CreditReference _creditReference = CreditReference)
{
CreditReference = _creditReference;
return CreditReference;
}
}
Controller Extension Class:
[ExtensionOf(classStr(PurchPurchaseOrderController))]
final class PurchPurchaseOrderController_Extension
{
protected void modifyContract()
{
PurchPurchaseOrderContract purchPurchaseOrderContract = contract as PurchPurchaseOrderContract;
PurchPurchaseOrderHeader purchPurchaseOrderHeader;
CreditReference creditReference;
next modifyContract();
creditReference = this.getCreditReference(purchPurchaseOrderHeader.PurchId);
purchPurchaseOrderContract.parmCreditReference(creditReference);
}
public CreditReference getCreditReference(PurchId _purchId)
{
PurchPurchaseOrderHeader purchPurchaseOrderHeader;
PurchParmUpdate purchParmUpdate;
select * from purchPurchaseOrderHeader
join purchParmUpdate
where purchParmUpdate.PurchId_SA == purchPurchaseOrderHeader.PurchId;
if(purchPurchaseOrderHeader.CreditReference == purchParmUpdate.CreditReference)
{
info("Header and Update are the same");
}else
{
info("Nope");
}
return purchPurchaseOrderHeader.CreditReference;
}
}
I also have a CreditReference field on the PurchTable but not sure if I need that.
Why isn’t the value being saved in the PurchPurchaseOrderHeader table? I am also looking for advice on what isn’t necessary to have in my existing code. For example any classes or methods that I have included to show.