Checkbox

Hi Experts.

I have loaded a checkbox on a form and it is always disabled when the form gets loaded.

It is bound to a new ud field. Everything is enabled, no Read only.

Is there something I am missing?

Thanks

Do any other UD fields show as editable? Or is that the only field from the UD table in your form?

Hi and thanks.

I have this on a PO form and I think once you approve the PO all fields are locked, even checkboxes added by users.

When I un-approve the PO I can use the checkbox.

The checkbox is to mark PO’s as shipped from the supplier.

I don’t have any UD fields on my POHeader, so run a test for me.

Add a button to your form.

private void epiButtonC1_Click(object sender, System.EventArgs args)
{
	EpiDataView edvPOHeader = (EpiDataView)(oTrans.EpiDataViews["POHeader"]);
	edvPOHeader.dataView[edvPOHeader.Row]["YourCustomField_c"] = true; //false?
}

And see if it will save.

If it does, you can unbind that checkbox and control it yourself.

Something like this perhaps:

public void InitializeCustomCode()
{
    epiCheckBoxC1.ReadOnly = true;
}

//Populate Value on load
private void edvPOHeader_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
    if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
    {
        if ((args.Row > -1))
        {
            epiCheckBoxC1.ReadOnly = false;
            EpiDataView edvPOHeader = (EpiDataView)(oTrans.EpiDataViews["POHeader"]);
            epiCheckBoxC1.Checked   = (bool)edvPOHeader.dataView[edvPOHeader.Row]["YourCustomField_c"];
        }
        else
        {
            epiCheckBoxC1.Checked = false;
            epiCheckBoxC1.ReadOnly = true;
        }

    }
}

//Set before save
private void oTrans_poAdapter_BeforeAdapterMethod(object sender, BeforeAdapterMethodArgs args)
{
    switch (args.MethodName)
    {
        case "Update":

            EpiDataView edvPOHeader = (EpiDataView)(oTrans.EpiDataViews["POHeader"]);
            edvPOHeader.dataView[edvPOHeader.Row]["YourCustomField_c"] = epiCheckBoxC1.Checked;

            break;
    }
}

Thanks for your help.

I will give it try and let you know.

Hi Kevin

Sorry for the delay.

This did not work.

If you add a button, as soon as the PO is approved the button is disabled.

Not sure what to try next.

Thanks

Steve