Select Company with Advanced JS via Web Services

406 views
Skip to first unread message

Eddie Armaos

unread,
Sep 4, 2021, 6:01:08 AM9/4/21
to so...@googlegroups.com
Hello everyone !

to date I have built a JS code which works normally last months

For example via https://xxxxxxx.oncloud.gr/s1services/JS/ModuleName/FunctionName   I can inseert a new item in Soft1. 

Without having defined the company anywhere, all entries inserting to company No1.

I would like to change it so that they go to company No2 in Soft1. How can this be done?


Best regards

Eddie Armaos


Liviu Buligan

unread,
Sep 4, 2021, 11:08:40 AM9/4/21
to Softone Developers Network
try to simply define it in your JS. 
ITEM.COMPANY=2;

or authenticate before execution OF js in  COMPANY: 2

Eddie Armaos

unread,
Sep 5, 2021, 4:17:29 AM9/5/21
to so...@googlegroups.com
Hello Liviu

Thank you for your reply. Your solution was very helpful, simple and it works! 
I thought I had to declare the company in this url (https://customer.oncloud.gr/s1services/JS/ModuleName/FunctionName) or somewhere else. 

Following your solution I cannot insert a new document at Saldoc for company 2, but only for company 1
All settings are the same in both companies. 

I got an error message "must give the document number"  Original:  "Πρέπει να δοθεί ο αριθμός του παραστατικού"

Code is very simple:

function testdoc () {
var myObj = X.CreateObj('SALDOC');
try {
myObj.DBINSERT;
var TblFin = myObj.FindTable('FINDOC');
TblFin.Edit;
TblFin.Company=2;
TblFin.Series = 7021;
TblFin.Trdr= 6132;
var TblLns = myObj.FindTable('ITELINES');
TblLns.Append;
TblLns.Company=2;
TblLns.MTRL = 14337;
TblLns.QTY1 = 1;
TblLns.PRICE = 50;
TblLns.Post;
var id = myObj.DBPOST;
if (id > 0)
return 'New id is:' + id;
}
catch (e) {
if (myObj != null)
return "General Error: " +e.message+" nObject Error: "+myObj.GETLASTERROR;
else
return "General Error: " +e.message;
}
finally {
}
}

Changing above statement for Company=2 to Company=1 it works.
Any idea? 

Kind regards


Eddie Armaos
--
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/9c036987-e1b2-4c19-ad98-1851676071f8n%40googlegroups.com.

Liviu Buligan

unread,
Sep 5, 2021, 6:50:45 AM9/5/21
to so...@googlegroups.com
check the settings on series 7021 on company 2
it should have autonumbering or you have to set the field CMPFINCODE

Λάβατε αυτό το μήνυμα επειδή έχετε εγγραφεί σε ένα θέμα στην ομάδα "Softone Developers Network" στις Ομάδες Google.
Για να απεγγραφείτε απ' αυτό το θέμα, επισκεφτείτε τη διεύθυνση https://groups.google.com/d/topic/soft1/9Yi9acz7ba0/unsubscribe.
Για να απεγγραφείτε απ' αυτή την ομάδα και όλα τα θέματά της, στείλτε ένα μήνυμα ηλεκτρονικού ταχυδρομείου στη διεύθυνση soft1+un...@googlegroups.com.
Για να κάνετε προβολή αυτής της συζήτησης στον ιστό, επισκεφτείτε τη διεύθυνση https://groups.google.com/d/msgid/soft1/CAKh9OYKc%2B5iXi3p0btPuAxteyB6dhSxwMow-hm4rEOrApdZ3_g%40mail.gmail.com.


--
Liviu Buligan

Eddie Armaos

unread,
Sep 5, 2021, 7:47:19 AM9/5/21
to so...@googlegroups.com
Thanks but I know about these settings and before my previous post I have checked them and tried both ways without success :-(
Maybe the error message is generic

The JS code is triggered from a simple webhook to the url: https://customer.oncloud.gr/s1services/JS/ModuleName/FunctionName 
The strange thing is that the same simple code is working in company 1 and no in company 2

Maybe i have to contact support

regards

Eddie

Για να κάνετε προβολή αυτής της συζήτησης στον ιστό, επισκεφτείτε τη διεύθυνση https://groups.google.com/d/msgid/soft1/CAEzg%3Dx4Wp%3DxZuSNEePN5hARKAdiEjUSJtr4DJ78sE6Z4gRBEmQ%40mail.gmail.com.

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

unread,
Sep 6, 2021, 6:43:57 AM9/6/21
to Softone Developers Network
I think one should be logged in on company 2 in order to send/store documents for company 2
The thing that worked for items / mtrl might just be "unexpected benefit of the process" , some of us might even be not so happy of this happening.

In my apps, I usually re-login if I even want to send document with different branch than the one I am currently logged on.

Eddie Armaos

unread,
Sep 6, 2021, 10:43:54 AM9/6/21
to so...@googlegroups.com
Thank you all for your replies.

The best solution is to use CreateSupport module to login to company No2 and post new document via SBSL or login with web services to this company 

Have a nice week !!


Eddie Armaos


Για να κάνετε προβολή αυτής της συζήτησης στον ιστό, επισκεφτείτε τη διεύθυνση https://groups.google.com/d/msgid/soft1/592162a0-8e77-4175-b87d-d28475e58c5fn%40googlegroups.com.

Liviu Buligan

unread,
Sep 6, 2021, 12:05:39 PM9/6/21
to so...@googlegroups.com
Eddie I believe it should work. 
I remember I did a custom that replicates a sales doc from company 1 to purchase doc to company 2. It was a JS on post, but it should work from WS/JS as well. 
You could test the JS code outside the WS to isolate the case. 

Liviu 

Pe 6 sept. 2021, la 17:43, Eddie Armaos <ear...@gmail.com> a scris:


Για να κάνετε προβολή αυτής της συζήτησης στον ιστό, επισκεφτείτε τη διεύθυνση https://groups.google.com/d/msgid/soft1/CAKh9OY%2BNHvOTdwdwGMxrMUVO4msuzb60R14_iAM8vQz4WmMQbQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages