I am using a REST Webservice as a Datasource.
To get the data, the Webservice GET function takes three Parameters "accountingClientId", "customerId" and "invoiceId".
The first two are mandatory, the third is optional.
I managed to do this by using ^ExecuteIfIsNotNull function in the URI of the GET,
https://service.company.com/Finance/OpenedPost?accountingClientId=@{accountingClientId}&customerId=@{customerId}^ExecuteIfIsNotNull("&invoiceId=",@invoiceId,"","")
and setting "invoiceId" to OPT in the view search method by VQL:
CREATE WRAPPER JSON "ds_egecko_financeOpenPost_4"
FOLDER = '/01 - connectivity/02 - base views'
DATASOURCENAME="ds_egecko_financeOpenPost"
TUPLEROOT '/JSONFile'
ROUTE HTTP 'http.CommonsHttpClientConnection,120000' GET 'OpenedPost?accountingClientId=@{accountingClientId}&customerId=@{customerId}^ExecuteIfIsNotNull("&invoiceId=",@invoiceId,"","")'
OUTPUTSCHEMA ("JSONFile" = 'JSONFile' : REGISTER OF (
"INVOICEID" = 'INVOICEID' : 'java.lang.String' (OPT) EXTERN,
"CUSTOMERID" = 'CUSTOMERID' : 'java.lang.String' (OBL) (DEFAULTVALUE='1009283') EXTERN URIPARAM,
"ACCOUNTINGCLIENTID" = 'ACCOUNTINGCLIENTID' : 'java.lang.String' (OBL) (DEFAULTVALUE='60') EXTERN URIPARAM,
"JSONArray" = 'JSONArray' : ARRAY OF (
"JSONArray" = 'JSONArray' : REGISTER OF (
"opNr" = 'opNr' : 'java.lang.String',
"customerId" = 'customerId' : 'java.lang.Integer',
"openAmountHauseCurrency" = 'openAmountHauseCurrency' : 'java.lang.Long',
"openAmountInvoiceCurrency" = 'openAmountInvoiceCurrency' : 'java.lang.Long',
"dunningDate" = 'dunningDate' : 'java.lang.String',
"invoiceId" = 'invoiceId' : 'java.lang.String',
"invoiceDate" = 'invoiceDate' : 'java.lang.String',
"invoiceType" = 'invoiceType' : 'java.lang.String',
currency = 'currency' : 'java.lang.String',
"opText" = 'opText' : 'java.lang.String'
)
)
)
);
CREATE TABLE "ds_egecko_financeOpenPost_4" I18N de (
"INVOICEID":int,
"CUSTOMERID":int,
"ACCOUNTINGCLIENTID":int,
"JSONArray":"ds_egecko_financeOpenPost_JSONArray"
)
FOLDER = '/01 - connectivity/02 - base views'
CACHE OFF
TIMETOLIVEINCACHE DEFAULT
ADD SEARCHMETHOD "ds_egecko_financeOpenPost"(
I18N de
CONSTRAINTS (
ADD "INVOICEID" (=) OPT ONE
ADD "CUSTOMERID" (=) OBL ONE
ADD "ACCOUNTINGCLIENTID" (=) OBL ONE
ADD "JSONArray" NOS ZERO ()
ADD "JSONArray" NOS ZERO ()
ADD "JSONArray"."opNr" NOS ZERO ()
ADD "JSONArray"."customerId" NOS ZERO ()
ADD "JSONArray"."openAmountHauseCurrency" NOS ZERO ()
ADD "JSONArray"."openAmountInvoiceCurrency" NOS ZERO ()
ADD "JSONArray"."dunningDate" NOS ZERO ()
ADD "JSONArray"."invoiceId" NOS ZERO ()
ADD "JSONArray"."invoiceDate" NOS ZERO ()
ADD "JSONArray"."invoiceType" NOS ZERO ()
ADD "JSONArray".currency NOS ZERO ()
ADD "JSONArray"."opText" NOS ZERO ()
)
OUTPUTLIST ("JSONArray"
)
WRAPPER (json "ds_egecko_financeOpenPost_4")
);
My Problem is now, that, although I get a complete result from the view, the returned INVOICEID is always NULL.
It works for the other two parameters.