...
Bloc de code | ||
---|---|---|
| ||
// FINAL_WebhookDefinition_final_suppliercategory
// Webhook definition
tableName = "final_suppliercategory"
specificOverload = CALL_SCRIPT( "FINAL_WebhookDefinitionOverload_<varscript>tableName</varscript>" )
tableSchema = DB_GET_TABLEINFO( "sw_data_<varscript>tableName</varscript>" )
tableSchemaDocument = DOCUMENT_CREATE_FROM_JSON( tableSchema )
languageCode = VARGET_SHELL( "languageCode", "WebhookDefinition" )
authorizedTables = TRANSLATE( "[{'tableName':'<varscript>tableName</varscript>'}]" )
JSONFieldsDefinition = TRANSLATE( "
{
'languageCode': '<varscript>languageCode</varscript>',
'strictFilterMode': 1,
'relatedTablesCount': 0,
'relatedTables': [ ],
'authorizedTables': <varscript>authorizedTables</varscript>,
'simpleFieldsList': 'CodeSupplier,label',
'extendedFieldsListToExclude': '',
'defaultFilters': [
],
'strictFilters': [
],
'strictOrderBy': [
],
'outOfMainTableFields': [
],
'standardOverload': {
},
'specificOverload':
<varscript>specificOverload</varscript>,
'simpleFields': [],
'extendedFields': [],
'strictFilterFields': [],
'defaultFilterFields': [],
'strictOrderByFields': []
}
" )
INCLUDE( "FuncWebhook_BuildDefinition" ) |
...
Création d’un nouveau webhook sur la table spécifique “sw_data_final_supplieraddress”.
Dictionnaire :
...
Script d’entrée : FINAL_WebhookSupplierAddress
FINAL_WebhookDefinition_final_supplieraddress
FINAL_WebhookDefinitionOverload_final_supplieraddress
FINAL_WebhookRules_final_supplieraddress
FINAL_WebhookRulesOverload_final_supplieraddress
Compléter webhook existant
Bloc de code | ||
---|---|---|
| ||
tableName = "final_supplieraddress"
entityName = "final_supplieraddress"
INCLUDE( "FuncWebhook_BuildEndpoint" ) |
Script de définition : FINAL_WebhookDefinition_final_supplieraddress
Info |
---|
Bien noter la subtilité sur le nom de l’entité dans le code du script : final_supplieraddress |
Bloc de code | ||
---|---|---|
| ||
// FINAL_WebhookDefinition_final_supplieraddress
JSONFieldsDefinition = TRANSLATE( "
{
'languageCode': '<varscript>languageCode</varscript>',
'strictFilterMode': 1,
'relatedTablesCount': 1,
'relatedTables': [ 'final_supplier_ID' ],
'authorizedTables': <varscript>authorizedTables</varscript>,
'simpleFieldsList': 'codefinal_supplieraddress,final_name',
'extendedFieldsListToExclude': '',
'defaultFilters': [
],
'strictFilters': [
],
'strictOrderBy': [
],
'outOfMainTableFields': [
],
'standardOverload': {
},
'specificOverload':
<varscript>specificOverload</varscript>,
'simpleFields': [],
'extendedFields': [],
'strictFilterFields': [],
'defaultFilterFields': [],
'strictOrderByFields': []
}
" )
INCLUDE( "FuncWebhook_BuildDefinition" ) |
Script de surcharge de définition : FINAL_WebhookDefinitionOverload_final_supplieraddress
Info |
---|
Bien noter la subtilité sur le nom de l’entité dans le code du script : final_supplieraddress |
Bloc de code | ||
---|---|---|
| ||
// FINAL_WebhookRulesOverload_final_supplieraddress
code = TRANSLATE( "<varscript>arg1</varscript>" )
verb = TRANSLATE( "<varscript>arg2</varscript>" )
dataInput = TRANSLATE( "<varscript>arg3</varscript>" )
ruleFields = TRANSLATE( "<varscript>arg4</varscript>" )
jsonResponse = DOCUMENT_CREATE_DOCUMENT()
response = DOCUMENT_SERIALIZE( jsonResponse, "json" )
RETURN( response ) |
Script de règles : FINAL_WebhookRules_final_supplieraddress
Info |
---|
Bien noter la subtilité sur le nom de l’entité dans le code du script : final_supplieraddress |
Bloc de code | ||
---|---|---|
| ||
// FINAL_WebhookRules_final_supplieraddress
code = TRANSLATE( "<varscript>arg1</varscript>" )
verb = TRANSLATE( "<varscript>arg2</varscript>" )
dataInput = TRANSLATE( "<varscript>arg3</varscript>" )
tableName = "final_supplieraddress"
entity = "final_supplieraddress"
internalcode = ""
codeTableName = TRANSLATE( "code<varscript>tableName</varscript>" )
codeEntityName = TRANSLATE( "code<varscript>entity</varscript>" )
internalcodeEntityName = TRANSLATE( "internalcode<varscript>entity</varscript>" )
scriptOverload = TRANSLATE( "FINAL_WebhookRulesOverload_<varscript>entity</varscript>" )
jsonResponse = DOCUMENT_CREATE_DOCUMENT()
ruleFields = DOCUMENT_CREATE_OBJECT( jsonResponse, "ruleFields" )
ruleOverloadFields = DOCUMENT_CREATE_OBJECT( jsonResponse, "ruleOverloadFields" )
ruleFieldsAdditionalTables = DOCUMENT_CREATE_OBJECT( jsonResponse, "ruleFieldsAdditionalTables" )
ruleOverloadFieldsAdditionalTables = DOCUMENT_CREATE_OBJECT( jsonResponse, "ruleOverloadFieldsAdditionalTables" )
// STANDARD RULES
IF( EQUALS( verb, "PUT" ) )THEN
IF ( JSON_EXISTS_FROM_PATH( dataInput, entity ) == 0 ) THEN
DOCUMENT_ADD_PROPERTY_TO_OBJECT( jsonResponse, "response", "0" )
DOCUMENT_ADD_PROPERTY_TO_OBJECT( jsonResponse, "errorMessage", "Standard rules error: Missing <varscript>entity</varscript> object in json data" )
response = DOCUMENT_SERIALIZE( jsonResponse, "json" )
RETURN( response )
ENDIF
jsonDataInput = JSON_GET_FROM_PATH( dataInput, entity )
VARINITIALIZE_SCRIPT_BYJSON( jsonDataInput )
IF ((LEN( code ) == 0) && (JSON_EXISTS_FROM_PATH( jsonDataInput, "<varscript>codeEntityName</varscript>" ))) THEN
code = JSON_GET_FROM_PATH( jsonDataInput, "<varscript>codeEntityName</varscript>" )
ENDIF
IF ( JSON_EXISTS_FROM_PATH( jsonDataInput, "<varscript>internalcodeEntityName</varscript>" ) ) THEN
internalcode = JSON_GET_FROM_PATH( jsonDataInput, "<varscript>internalcodeEntityName</varscript>" )
ENDIF
row_ID = CALL_SCRIPT( "Func_GetIDFromCode", "sw_data_<varscript>tableName</varscript>", "<varscript>code</varscript>", "<varscript>internalcode</varscript>" )
ENDIF
// Rule overload
ruleOverloadJsonResponse = CALL_SCRIPT( scriptOverload, code, verb, dataInput, ruleOverloadFields )
IF( JSON_EXISTS_FROM_PATH( ruleOverloadJsonResponse, "response" ) )THEN
response = JSON_GET_FROM_PATH( ruleOverloadJsonResponse, "response" )
IF( EQUALS( response, "0" ) )THEN
IF( JSON_EXISTS_FROM_PATH( ruleOverloadJsonResponse, "response" ) )THEN
errorMessage = JSON_GET_FROM_PATH( ruleOverloadJsonResponse, "errorMessage" )
DOCUMENT_ADD_PROPERTY_TO_OBJECT( jsonResponse, "errorMessage", errorMessage )
ELSE
DOCUMENT_ADD_PROPERTY_TO_OBJECT( jsonResponse, "errorMessage", "Specific rules error: No error message defined" )
ENDIF
DOCUMENT_ADD_PROPERTY_TO_OBJECT( jsonResponse, "response", response )
response = DOCUMENT_SERIALIZE( jsonResponse, "json" )
RETURN( response )
ENDIF
ENDIF
DOCUMENT_ADD_PROPERTY_TO_OBJECT( jsonResponse, "response", "1" )
response = DOCUMENT_SERIALIZE( jsonResponse, "json" )
RETURN( response ) |
Script de surcharge de règles : FINAL_WebhookRulesOverload_final_supplieraddress
Info |
---|
Bien noter la subtilité sur le nom de l’entité dans le code du script : final_supplieraddress |
Bloc de code | ||
---|---|---|
| ||
// FINAL_WebhookRulesOverload_final_supplieraddress
code = TRANSLATE( "<varscript>arg1</varscript>" )
verb = TRANSLATE( "<varscript>arg2</varscript>" )
dataInput = TRANSLATE( "<varscript>arg3</varscript>" )
ruleFields = TRANSLATE( "<varscript>arg4</varscript>" )
jsonResponse = DOCUMENT_CREATE_DOCUMENT()
response = DOCUMENT_SERIALIZE( jsonResponse, "json" )
RETURN( response ) |
Compléter webhook existant
Script de définition : FINAL_WebhookDefinition_interventionoperationrange
...