solop-develop / adempiere-grpc-server

ADempiere gRPC Server example of integration
GNU General Public License v2.0
0 stars 9 forks source link

fix: Callout with `@script` as MRule. #860

Closed EdwinBetanc0urt closed 2 months ago

EdwinBetanc0urt commented 2 months ago

Request

curl 'http://20.12.0.164/api/user-interface/run-callout/450/M_Product_ID/@script:beanshell:fill_SerNoFromProduct' \
  -X POST \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxMDAxMDQzIiwiQURfQ2xpZW50X0lEIjoxMSwiQURfT3JnX0lEIjo1MDAwNiwiQURfUm9sZV9JRCI6MTAwMDAwMSwiQURfVXNlcl9JRCI6MTAwMDAwNywiTV9XYXJlaG91c2VfSUQiOjUwMDA2LCJBRF9MYW5ndWFnZSI6ImVzX01YIiwiaWF0IjoxNzI0MzU4MTI4LCJleHAiOjE3MjQ0NDQ1Mjh9.9jUSfnaNLppRr4kYhsO1BIn9p7n4u6Lvrl1MRstLu3I' \
  --data-raw '{"tab_id":450,"context_attributes":{"A_Asset_Action":"MD","Processed":false,"A_AssetType":"MFX","Processing":false,"AD_Client_ID":11,"AD_Org_ID":50006,"IsActive":true,"M_Product_ID":1000001,"A_Asset_Group_ID":50006,"IsInPosession":false,"M_Locator_ID":50006,"AD_User_ID":1000007,"IsOwned":false,"IsDepreciated":false,"IsFullyDepreciated":false,"A_Asset_Status":"AC","IsDisposed":false,"Created":"2024-08-17 12:37:20","CreatedBy":1000000,"Updated":"2024-08-21 04:48:23","UpdatedBy":1000000},"column_name":"M_Product_ID","callout":"@script:beanshell:fill_SerNoFromProduct","value":1000001}'

Response

Before this changes

{
    "result": "Callout Invalid: javax.script.ScriptException: Sourced file: inline evaluation of: ``import org.compiere.util.DB; String serNo = \"\"; String productType = \"\";  if (A_ . . . '' : Error in method invocation: Method getValue( java.lang.String ) not found in class'org.spin.grpc.service.UserInterface' : at Line: 5 : in file: inline evaluation of: ``import org.compiere.util.DB; String serNo = \"\"; String productType = \"\";  if (A_ . . . '' : A_Tab .getValue ( \"M_Product_ID\" ) \n in inline evaluation of: ``import org.compiere.util.DB; String serNo = \"\"; String productType = \"\";  if (A_ . . . '' at line number 5",
    "values": {
        "Value": null,
        "SerNo": null,
        "Name": null,
        "IsActive": true,
        "A_Parent_Asset_ID": null,
        "M_Product_ID": 1000001,
        "IsInPosession": false,
        "C_BPartner_ID": null,
        "IsOwned": false,
        "IsDepreciated": false,
        "AssetDepreciationDate": null,
        "IsDisposed": false,
        "JAU01_AssetMark_ID": null,
        "JAU01_AssetModel_ID": null
    }
}

After this changes

Set SerNo value.

{
    "result": "",
    "values": {
        "Value": null,
        "SerNo": "12214",
        "Name": null,
        "IsActive": true,
        "A_Parent_Asset_ID": null,
        "M_Product_ID": 1000001,
        "IsInPosession": false,
        "C_BPartner_ID": null,
        "IsOwned": false,
        "IsDepreciated": false,
        "AssetDepreciationDate": null,
        "IsDisposed": false,
        "JAU01_AssetMark_ID": null,
        "JAU01_AssetModel_ID": null
    }
}

Additional context

fixes https://github.com/solop-develop/frontend-core/issues/2582