I created a extension table for VendTable. Then Added two fields. One is VendorRank. and I added these two fields on VendTable Form extension form. In this post, i will show how to get the current record inside datasource field OnValidating event method.
- Create an Extension Class for VendTable form. Ex: ABVendTableForm_Extension.
- Now Expand VendTable.Extension form that is created and where you added the two fields.
- Now Expand the Datasource VendTable on form > Expand Fields > Expand Field VendorRank > Expand Events > Right Click on “Onvalidating” > Click “Copy Event handler Method”
- Now Paste that inside the class you created in step 1.
- Code looks like this
class ABVendTableForm_Extension
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataFieldEventHandler(formDataFieldStr(VendTable, VendTable, VendorRank), FormDataFieldEventType::Validating)]
public static void VendorRank_OnValidating(FormDataObject sender, FormDataFieldEventArgs e)
{
boolean ret;
FormDataSource VendTable_ds = sender.datasource(); // Code to get Datasource
VendTable VendT = VendTable_ds.cursor(); //Code to get Current Record
ret = true;
if(VendT.VendorRank == 50)
{
ret = checkFailed("Rank 50 is not possible"); //I am just throwing an error if entered value on Vendor Rank is 50
}
sender.setValue(ret); //returning the error.
}
}
Leave a comment