how to fetch a record from the web service in action script?
https://docs.axelor.com/adk/6.1/dev-guide/web-services/advanced.html#action-service
if it’s not what you ask, give more details
How can we make an http request from action script? I tried to use the built in fetch in javascript, but it is throwing with an error like fetch is undefined. So I wanted you guys to help me with how i can make http request from axelor action script. Thanks in advance.
Please no private message just for copying a post.
No I can’t sorry.
Read this :
-
Learn everything you can about API
-
And make your tests with POSTMAN
an example from someone : Postman
Even this topic is old, the question is worth to answer.
Here is a quick and dirty example of such a script (and yes, it is not obvious one)
<action-script name="action-request-price-rules-list" model="com.axelor.meta.db.MetaJsonRecord">
<script language="groovy" transactional="false"><![CDATA[
def _LOG = org.slf4j.LoggerFactory.getLogger(java.lang.invoke.MethodHandles.lookup().lookupClass())
def _queryObj = com.axelor.db.Query.of(com.axelor.studio.db.WsConnector)
_queryObj = _queryObj.filter("self.name=?1","executeGetRulesListReq")
// The call to connector itself, and it is known that Connector with the given name exists
def _res = com.axelor.inject.Beans.get(Class.forName('com.axelor.studio.service.ws.WsConnectorService'))
.callConnector(_queryObj.fetchOne(0), null, [:]).get("_1")
_LOG.error('Request result: '+_res+',\n result type: '+_res.class)
def _obj = $json.create('PriceControlRules')
_obj.extName = _res.toString()
$response.setValues(_obj)
]]></script>
</action-script>
Model is a simple Studio Json model, nothing special. It has only one string field: extName.
For sure Logger is used for debug purposes only.