Como no todo queda a la primera o se tenga que modificar por cualquier razón la consulta personalizada, les dejo el ejemplo básico de como modificar una consulta personalizada
Para modificar la consulta creada anteriormente hacemos la siguiente petición de tipo PATH
{
"SqlCode":"sql02",
"SqlName":"listPrices",
"SqlText":"select a.ItemCode
,a.PriceList
,a.Price
,b.ListName
,z.[ItemName]
from [ITM1] a
, [OPLN] b
, [OITM] z
where a.[PriceList] =:listaPrecios
and a.[Price] <>0
AND a.[PriceList] = b.[ListNum]
AND a.[ItemCode] = z.[ItemCode]
",
"ParamList" : "listaPrecios"
}
En el service layer también tenemos la forma para crear nuestras consultas personalizadas, aunque tiene algunas limitaciones pero nos pueden ser muy útiles.
Para ello utilizaremos SQLQueries y el ejemplo básico seria de la siguiente manera
Hacemos la petición POST
https://localhost:50000/b1s/v1/SQLQueries
En el body le metemos el contenido JSON
{
"SqlCode":"sql02",
"SqlName":"listPrices",
"SqlText":"select ItemCode,PriceList
from [ITM1]
where [PriceList] =:listaPrecios ",
"ParamList" : "listaPrecios"
}
Para traer la el catalogo de listas de precios usaremos la siguiente URL en GET
https://localhost:50000/b1s/v1/PriceLists?$select=PriceListNo,PriceListName&$filter=Active eq 'tYES' and substringof('TRIT',PriceListNo) or substringof('TRIT',PriceListName)
Como pueden observar usamos la funcion substringof como el equivalente al like de SQL
Lo que haremos en esta ocasión en hacer la consulta al service layer para usarlo en un Select2 vía AJAX y PHP primera mente usaremos la siguiente petición de tipo GET URL
https://localhost:50000/b1s/v1/Users?$select=InternalKey,UserCode,Group,UserName&$filter=Group eq 'ug_Regular' and substringof('Julio',UserName) or substringof('Julio',UserCode)&$orderby=InternalKey
Como ven usamos la función substringof que seria el equivalente en SQL al like ‘%%’
Quedando mas o menos asi
Ahora transformamos la petición a una función de PHP en la que recibimos la cookie y el filtro para buscar los usuarios
Ahora en el archivo de consulta se usaría de la siguiente forma, hacemos el Login, consultamos, hacemos el Logout, y formamos la cadena JSON de la siguiente forma
Usamos cookies en nuestro sitio web para brindarle la experiencia más relevante recordando sus preferencias y visitas repetidas. Al hacer clic en "Aceptar", acepta el uso de TODAS las cookies.
This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.