Saturday, January 19, 2019

View Recurrence Data on Event Record through ODBC

Custom fields are supported via ODBC and reflecting the recurrence data to custom fields can make the data available via ODBC. Create the following custom CRM fields that will be available on the Event records.

Customization > Lists, Records, & Fields > CRM Fields > New 
- Series Start Date (Type: free - form text)(Stored Value = Y)
- End By (Type: free - form text)(Stored Value = Y)
- No End Date (Type: checkbox)(Stored Value = Y)

Deploy a User Event script that triggers upon saving. The script loads the record again, copies the values to the custom fields created and saves the record.

Customization > Scripting > Scripts > New > User Event
function AfterSubmit(type)
{
                //Get record type and ID then pass those into the LoadRecord function
                var recordid = nlapiGetRecordId();
                var record = nlapiLoadRecord('calendarevent',recordid);

                //Set Values
                var SeriesStart = record.getFieldValue('seriesstartdate'); //get the value of the Series Start Date standard field
                nlapiLogExecution('DEBUG','Series Start Date ODBC: ' + SeriesStart);
                record.setFieldValue('custevent5',SeriesStart); //set the value to the custom field created. custevent5 is the internal ID of the custom field

                var SeriesEnd = record.getFieldValue('endbydate'); //get the value of the End By standard field
                nlapiLogExecution('DEBUG','Series Start Date ODBC: ' + SeriesEnd);
                record.setFieldValue('custevent6',SeriesEnd); //set the value to the custom field created. custevent6 is the internal ID of the custom field

                var NoEnd = record.getFieldValue('noenddate'); //get the value of the No End Date standard field
                nlapiLogExecution('DEBUG','Series Start Date ODBC: ' + NoEnd);
                record.setFieldValue('custevent7',NoEnd); //set the value to the custom field created. custevent7 is the internal ID of the custom field
                //}
                var id = nlapiSubmitRecord(record, true);
                id = nlapiSubmitRecord(record, true);
}

Deploy the script on Event records and you can then pull the custom fields created via ODBC which actually contains the recurrence data on the event records that you need.

 

No comments:

Post a Comment