Save original data if current record is not saved

Hi All,

In one of the parameters screen I have added three new check boxes say A, B and C. If A is checked then either B or C field should be checked. For this I have overridden the validateWrite method of the datasource. The validation doesn’t work when record is not saved.

Step 1: Check A and B. Record gets saved.

Step 2: Check A, uncheck B and save record. Validation is done and error is displayed.

Step 3: Close the form. Ax asks whether to save the record. If No then the record is saved with B unchecked.

In step 3, the record should be saved with ‘B’ checked (because B was checked before saving) . How to imply this ?

Regards,

Raghavendra.

if (Table.A == NoYes::Yes && ( Table.B == NoYes::No || Table.C == NoYes::No)

{

return //error here;

}

Hi Kranthi,

I have written this logic in the validate write method. It works only if the record is saved. If the form is closed without saving then the record is not saved with original data.

The method is given below,

public boolean validateWrite()

{

boolean ret;

ret = super();

if(this.cnlWFJAllocateMarkupHeaderToLine && !this.cnlWFJAllocateAll && !this.cnlWFJAllocateOnlyReceived)

{

ret = checkFailed(strfmt("@CNL4064", “@SYS26754”,"@SYS4465" ));//Either ‘%1’ or ‘%2’ should be checked, Allocate all, Received

}

return ret;

}

Regards,

Raghavemdra.

Can you explain with an example?

Dear Kranti,

step 1 : Say A an B fields are checked.

step 2 : Uncheck field B and close the form. Ax ask “Changes have been made in the form. Save changes?”

step 3 : say No.

step 4 : If we open the form again, field B should be checked because the form was closed without saving the data. Issue is field B is unchecked.

Regards,

Raghavendra.

Hi Raghavendra,

You need to do two changes in your code which i have written below.

Instead of writting “this” better to wrtie Datasource name which contains the current record which is not saved.

//DataSourcename —> DS

Public boolean ValidateWrite()

{

boolean ret;

;

if((DS.cnlWFJAllocateMarkupHeaderToLine == NoYes::Yes ) && (DS.cnlWFJAllocateAll == NoYes::No) && (DS.cnlWFJAllocateOnlyReceived == NoYes::No)

{

ret = checkFailed(strfmt("@CNL4064", “@SYS26754”,"@SYS4465" ));//Either ‘%1’ or ‘%2’ should be checked, Allocate all, Received

}

else

{

ret = super();

}

return ret;

}

Regards

Abbas