Set Checkbox to True on Form Load For Specific Customisation

Hi

We need to set a checkbox to True when a new record is created in the RMAHead table. We would use a BPM but we only want the checkbox marked as true when a specific customised form is used.

The field name is WarrantyRMA_c and it is in the RMAHead table, in vantage the code was

Private Sub edvRMAHead_EpiViewNotification(view As EpiDataView, args As EpiNotifyArgs) Handles edvRMAHead.EpiViewNotification
'// ** Argument Properties and Uses **
'// view.dataView(args.Row)("[FieldName]")
'// args.Row, args.Column, args.Sender, args.NotifyType
'// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
If (args.NotifyType = EpiTransaction.NotifyType.AddRow) Then
If (args.Row > -1) Then

Dim RMAHead As EpiDataView = CType(oTrans.EpiDataViews("RMAHead"), EpiDataView)
RMAHead.dataview(RMAHead.Row)("Checkbox01") = "TRUE"


	End If
End If

End Sub

Converted to C# (using an online converter) it is

private void edvRMAHead_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
//// ** Argument Properties and Uses **
//// view.dataView(args.Row)("[FieldName]")
//// args.Row, args.Column, args.Sender, args.NotifyType
//// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
if ((args.NotifyType == EpiTransaction.NotifyType.AddRow)) {

	if ((args.Row > -1)) {
		EpiDataView RMAHead = (EpiDataView)oTrans.EpiDataViews("RMAHead");
		RMAHead.dataview(RMAHead.Row)("WarrantyRMA_c") = "TRUE";


	}
}

}

When I add this to the Form Event Wizard as a EpiViewNotification and select Update Selected code and test the code i get theses compile errors

Error: CS1955 - line 97 (588) - Non-invocable member ‘Ice.Lib.Framework.EpiTransaction.EpiDataViews’ cannot be used like a method.
Error: CS1061 - line 98 (589) - ‘Ice.Lib.Framework.EpiDataView’ does not contain a definition for ‘dataview’ and no extension method ‘dataview’ accepting a first argument of type ‘Ice.Lib.Framework.EpiDataView’ could be found (are you missing a using directive or an assembly reference?)

I am a complete novice regarding any sort of coding so please bear this in mind.

thanks in Advance

Mark

try dataView instead of dataview. Also, this seems like a good place to use a pre-processing BPM instead of a form customization to set the field value.
Also, try using brackets instead of parenthesis when indexing your row

RMAHead.dataView[RMAHead.Row][“WarrantyRMA_c”] = “TRUE”;

2 Likes

Use the BPM. You can use a condition on the customization I’d in the call context.

Proper c# syntax would be to remove the quotes and make TRUE lower case, true.

RMAHead.dataView[RMAHead.Row][“WarrantyRMA_c”] = true;

Brilliant, many thanks.

My last bit of the code now reads

EpiDataView RMAHead = (EpiDataView)oTrans.EpiDataViews[“RMAHead”];
RMAHead.dataView[RMAHead.Row][“WarrantyRMA_c”] = true;

and the checkbox is ticked on form load