Creating New Records

Aside from changing existing data you will want to create new records. Remember however that this is only possible on certain tables so check the "Supported Tables and Actions" for the version you are using.

First you need to issue the "New" command on the appropriate object. For example say you want to create a new work order.

loITRDS.OWORKORDERS.New()

This will place a blank object in oData. All you need to do now is populate the fields with values as follows (note we check for errors after each "ADDFIELDVALUE" as errors may occur through trying to assign a value of the incorrect data type);

If not loITRDS.OWORKORDERS.AddFieldValue("account","2744262")
* Error
Endif

If not loITRDS.OWORKORDERS.AddFieldValue("wo_type","S")
* Error
Endif

If not loITRDS.OWORKORDERS.AddFieldValue("Level",1)
* Error
Endif

If Not loITRDS.OWORKORDERS.AddFieldValue("Department","OPS")
* Error
Endif

And then issue the save command

If not loITRDS.OWORKORDERS.Save()
* Access error message if you want
lcErrorMessage = loITRDS.OWORKORDERS.cErrorMsg
* Handle Error
Endif

Remember that a great deal of validation goes on when you save this data so it's very important to check for errors when saving data


Last Updated: 11/05/2004