How to set Custom Defaults and Validations for web services in CTAPI.


How to set Custom Defaults and Validations for web services in CTAPI. As of RELEASE builds post 2017/1/1, you are now able to overwrite defaults and validations in two single files. This is now the preferred place to make customizations, as it will avoid overwriting changes with new release builds of CTAPI.

The file for Defaults customizations is named: custom.default.ctDynamicsSL.xml and is located in your DEFAULTCONFIGDIRECTORY. (Path defined in your DSLCONFIGFILE, default: c:\inetpub\xctFiles\config\)

The file for Validations customizations is named: custom.validate.ctDynamicsSL.xml and is located in your VALIDATIONCONFIGDIRECTORY. (Path defined in your DSLCONFIGFILE, default: c:\inetpub\xctFiles\config\)

All customizations for defaults and validations for all CTAPI web services are contained in these two files.

Definition of the custom.default.ctDynamicsSL.xml file:

<?xml version='1.0' encoding='utf-8' ?>

<VARIABLES>

<!—All defaults entries are located as elements underneath the VARIABLES element in the xml document-->

<VARIABLE SERVICE='The.Full.Type.Name.Of.CTAPI.Web.Service' FUNCTION='The.Edit.Function.Being.Called' ID='The.Field.To.Default' DEFAULTTYPE='The.Default.Type' PARMS='Optional.Parameters'>The.VALUE/PROC/CODE.To.Default</VARIABLE>

<!--eg:The following example will set a default of 'A' for the Vendor.Status table.field-->

<VARIABLE SERVICE='ctDynamicsSL.financial.accountsPayable.maintenance.vendorMaintenance' FUNCTION='editVendor' ID='inItem.Status' DEFAULTTYPE='TEXT' PARMS=''>A</VARIABLE>

<VARIABLE SERVICE='ctDynamicsSL.financial.accountsPayable.maintenance.vendorMaintenance' FUNCTION='editVendor' ID='inItem.ExpSub' DEFAULTTYPE='PROC' PARMS='inItem.ExpSub,fieldName=EXPSUB'>xct_spDSLGetAPSetupValue</VARIABLE>

</VARIABLES>

 

ID: (The field to set)

1.      inItem – Always used to represent the Table/Object being defaulted. (not the field)

DEFAULTTYPE:  (TEXT, PROC, CODE)

               1.            TEXT - sets the field value to the value listed in this xml element.

               2             PROC - sets the field value to the value returned by the stored procedure listed in the xml element value. (optional: PARMS attribute listing stored procedure parameters)

               3.            CODE - sets the field value to the value returned by performing an eval on the code listed in the xml element value.

PARMS: (An optional, comma-delimitated list of parameters used for PROC Type defaults)

1.      Variables from the inItem object that match stored procedure variable names. 

e.g.: PARMS=’inItem.Status’

2.      Rename an inItem object variable to a different stored procedure variable name.

e.g.: PARMS=’VendStatus=inItem.Status’

3.      Hardcoded Stored procedure variable values.

e.g.: PARMS=’Active=1’

Definition of the custom.validate.ctDynamicsSL.xml file:

<?xml version='1.0' encoding='utf-8' ?>

<VARIABLES>

<!—All validation entries are located as elements underneath the VARIABLES element in the xml document-->

<!--VARIABLE SERVICE='The.Full.Type.Name.Of.CTAPI.Web.Service' FUNCTION='The.Edit.Function.Being.Called' ID='The.Field.To.Validate' VALIDATETYPE='The.Validation.Type' PARMS='Optional.Parameters'>The.LIST/PROC/NUMBERRANGE/DATERANGE/CODE.To.Validate</VARIABLE-->

<VARIABLE SERVICE='ctDynamicsSL.financial.accountsPayable.maintenance.vendorMaintenance' FUNCTION='editVendor' ID='inItem.TaxDflt' VALIDATETYPE='LIST'>A,V</VARIABLE>

<VARIABLE SERVICE='ctDynamicsSL.financial.accountsPayable.maintenance.vendorMaintenance' FUNCTION='editVendor' ID='inItem.Terms' VALIDATETYPE='PROC' PARMS='inItem.Terms'>xct_spDSLvalidateVendorTerms</VARIABLE>

</VARIABLES>

 

ID: (The field to set)

1.      inItem – Always used to represent the Table/Object being defaulted. (not the field)

VALIDATETYPE:  (LIST, PROC, NUMBERRANGE, DATERANGE, CODE)

1.      LIST – a comma delimitated list of text values that are valid.

2.      PROC – validates based on returnValue returned by the stored procedure listed in the xml element value. (optional: PARMS attribute listing stored procedure parameters)

3.      NUMBERRANGE – a comma delimitated range of doubles.

e.g.: 1,5

4.      DATERANGE – a comma delimitated range of dates.

e.g.: 1/1/2016,1/1/2019

5.      CODE – validates the Boolean returned by performing an eval on the code listed in the xml element value.

PARMS: (An optional, comma-delimitated list of parameters used for PROC Type validations)

6.      Variables from the inItem object that match stored procedure variable names. 

e.g.: PARMS=’inItem.Status’

7.      Rename an inItem object variable to a different stored procedure variable name.

e.g.: PARMS=’VendStatus=inItem.Status’

8.      Hardcoded Stored procedure variable values.

e.g.: PARMS=’Active=1’