Cancel Sales Document via WebService

611 views
Skip to first unread message

Dobromir Mateev

unread,
Dec 5, 2019, 5:02:27 AM12/5/19
to Softone Developers Network
Hello,

I found out that in order to cancel a sales document with reversal i need to:

1. Create new document with cancelling SERIES, FINDOC.ISCANCEL=0 and FINDOC.ORIGIN=6 - This works fine. I am using SetData on SALDOC object and no KEY.
2. Update the first document with FINDOC.FINDOCS = the id from previous step, and FINDOC.ISCANCEL=2. - This doesn't work. I am using SetData on SALDOC with KEY=id from first step.

FINDOCS is updated correctly, but ISCANCEL is not updated.

I need to set FINDOC.ISCANCEL to be 2. Is to possible via the webservice , or should I update it directly in the database ?

Νίκος Μάλιακκας

unread,
Dec 5, 2019, 1:20:17 PM12/5/19
to Softone Developers Network
I think that it goes this way:
newfindoc.FINDOCS=cancellingfindoc.FINDOC
newfindoc.ORIGIN=6

cancellingfindoc.ISCANCEL=1

I am doing it in REST javascript, so it should be working via webservices too.

Dobromir Mateev

unread,
Dec 6, 2019, 4:16:14 AM12/6/19
to Softone Developers Network
The last step fails for me.

{
  "Service": "SetData",
  "ClientId": "...",
  "AppId": "2001",
  "Object": "SALDOC",
  "Key": 983,
  "Data": {
    "SALDOC": [
      {
        "ISCANCEL": 1
      }
    ]
  }
}

Response
{
    "success":false,
    "error": "Record can not be modify"
}

Am I missing something?




On Thursday, December 5, 2019 at 12:02:27 PM UTC+2, Dobromir Mateev wrote:

Liviu Buligan

unread,
Jan 7, 2022, 9:57:34 AM1/7/22
to Softone Developers Network
I choose to create a JS (called by the WS) that will cancel the object via XCMD:1001. The function is called, the response is success: true. However the cancellation did not happened

here is my code:

function CancelBackListedOrders(obj){

        var resp = {};
        resp.success = false;
        if ((obj.clientID) && (obj.clientID != "")) {
                try {
                //obj.Key is sent by the caller
                        var myObj = X.CreateObj('SALDOC');                
                        myObj.DBLocate(obj.Key);
                         myObj .EXEC('XCMD:1001');
                       
                        resp.success = true;
                        resp.warning = "OK";
                }
                catch (e) {
                        resp.error = "Error: "+e.message;
                }
        }
        else {
                resp.error = "Authenticate failed due to invalid credentials!"; ;
        }
        return resp;
}


Any idea? Pls help!

Antony Georgopoulos

unread,
Jan 7, 2022, 10:20:07 AM1/7/22
to Softone Developers Network
I believe that the problem lies at this line of code:

myObj .EXEC('XCMD:1001');

This command Opens a new window for the user where he chooses if he wants to cancel.

It will not produce any error, if it doesn't execute for your code to catch.

Maybe there is a parameter that chooses yes, so it continues, or you can try with

X.SETPARAM('WARNINGS','OFF'); X.SETPARAM('NOMESSAGES',1);  

and see if it executes.

Liviu Buligan

unread,
Jan 7, 2022, 10:54:37 AM1/7/22
to so...@googlegroups.com
Hi Antony,
thank you for the reply.
You are right, the popup is showing if i run the code in JS locally. 
I tried already your suggestion, but it doesn't care.
It looks like I need to run some SQL updates if there is another way to do this... :(


--
Softone Developers Network group.
To post to this group, send email to so...@googlegroups.com
---
Λάβατε αυτό το μήνυμα επειδή έχετε εγγραφεί στην ομάδα "Softone Developers Network" των Ομάδων Google.
Για να απεγγραφείτε απ' αυτή την ομάδα και να σταματήσετε να λαμβάνετε μηνύματα ηλεκτρονικού ταχυδρομείου απ' αυτή, στείλτε ένα μήνυμα ηλεκτρονικού ταχυδρομείου στη διεύθυνση soft1+un...@googlegroups.com.
Για να κάνετε προβολή αυτής της συζήτησης στον ιστό, επισκεφτείτε τη διεύθυνση https://groups.google.com/d/msgid/soft1/d5233a31-d5cb-40a3-8a1d-14713c83de89n%40googlegroups.com.


--
Liviu Buligan

Antony Georgopoulos

unread,
Jan 10, 2022, 5:12:34 AM1/10/22
to Softone Developers Network
Try this code.

function CancelSaldoc(findoc) {
 var saldoc = X.CREATEOBJ('SALDOC');
 
 saldoc.DBLOCATE(findoc);
 
 var findoc = saldoc.FINDTABLE('FINDOC');
 
 findoc.EDIT;
 findoc.ISCANCEL = 1;
 findoc.POST;
 
 saldoc.DBPOST;
 
 findoc.FREE;
 saldoc.FREE;
}

Just directly put ISCANCEL = 1 and post the object.

I have tried and sql monitor produces the same transactions as with XCMD:1001

Liviu Buligan

unread,
Jan 13, 2022, 2:19:56 AM1/13/22
to so...@googlegroups.com
Thank you Antony. It is working perfectly.


Για να κάνετε προβολή αυτής της συζήτησης στον ιστό, επισκεφτείτε τη διεύθυνση https://groups.google.com/d/msgid/soft1/1c7990cf-39de-46e9-bca4-5bd5800816f6n%40googlegroups.com.


--
Liviu Buligan
Reply all
Reply to author
Forward
0 new messages