SBX - Search With Button

SBX - Forum Post Title

entering Note, or Link in Sales Order, via web services (OData / SOAP)

Microsoft Dynamics NAV Forum

vmanta asked a question on 10 Jun 2019 11:19 AM
My Badges

Question Status

Verified

Is this possible?

 
If not possible, can someone suggest a solution (our problem described below).
Thanks!

-----------------------------------------------

Background:

US Millitary APO/FPO customers, provide alternate "consolidation point/forwarding" address, in US, for cases where the package exceeds the limits imposed by USPS (over 70LBs, or over 130inch combined Length+Girth ).

We have a need for our Warehouse staff  to be able to see these "alternate address" that may be attached to an APO/FPO order... in case the package exceeds those limits.

We enter Sales Order data into NAV (2016) by using Odata Web Services  (could also use SOAP if need be).

We thought we could put this info  (the alternate address) into the Sales Order -> Notes, so that our Warehouse staff gets a "popup" notifying them  that there are Notes and then they are able to read them, at ship time.

Reply
I Gusti Made Ari Permadi responded on 11 Jun 2019 3:14 AM
My Badges
Suggested Answer

It is possible using SOAP, create a codeunit and write a function to write a note .

Tested working :

Publish the codeunit in Web Service :

Call in Postman :

Result in NAV :

Sample code :

[External] WriteSalesOrderNote(OrderNo : Code[20];Note : Text)
SalesHeader.GET(SalesHeader."Document Type"::Order,OrderNo);

RecordLink."Record ID" := SalesHeader.RECORDID;
RecordLink.Type := RecordLink.Type::Note;
TypeHelper.WriteRecordLinkNote(RecordLink,Note);
RecordLink.Created := CREATEDATETIME(TODAY,TIME);
RecordLink."User ID" := USERID;
RecordLink.Company := COMPANYNAME;
IF NOT RecordLink.INSERT THEN RecordLink.MODIFY;


Name	        DataType	Subtype	       Length
TypeHelper	Codeunit	Type Helper	
RecordLink	Record	        Record Link	
SalesHeader	Record	        Sales Header	


Reply
I Gusti Made Ari Permadi responded on 11 Jun 2019 8:52 PM
My Badges

I checked using OData is also possible :

No additional field but with new page

workaround is you need to create page with SourceTableTemporary set to yes , and put the code to write the note inside OnModifyRecord. (only need additional page)

no additional page but with new field

you can create additional field for the note in sales header table , then add code to transfer the value from this field to Note (record link) ,put the code to write the note inside OnModifyRecord.

Sample using page with temporary table and using "Ship-to Address" field to transfer the note text :

Call in postman :

Result in NAV

OnModifyRecord() : Boolean
SalesHeader.GET(SalesHeader."Document Type"::Order,Rec."No.");

RecordLink."Record ID" := SalesHeader.RECORDID;
RecordLink.Type := RecordLink.Type::Note;
TypeHelper.WriteRecordLinkNote(RecordLink,Rec."Ship-to Address");
RecordLink.Created := CREATEDATETIME(TODAY,TIME);
RecordLink."User ID" := USERID;
RecordLink.Description := Rec."Ship-to Address";
RecordLink.Company := COMPANYNAME;
IF NOT RecordLink.INSERT THEN RecordLink.MODIFY;


Reply
vmanta responded on 12 Jun 2019 7:54 AM
My Badges

I was hoping there is a way without any development.  I work for the end-user company.

(I write code, but not C/AL code) and we do not have NAV Dev licence.

Our Partner, i feel they have taken advantage of us (of the fact that there was no-one to check their invoices - what they have been billing us for - and their $200/hr fees)

I have wrote all kinds of integrations with NAV - using web services only - to pull data and write data to NAV...   but for this case I think we just can't get around having a "customization".

I was also considering using the Sales Order Comments... but for some strange reason I just cannot write a comment to a Sales Order, via ODaTA, after I exposed PAGE 67 (Comment Sheet) as web service (I get :    Error (OData): The Sales Comment Line already exists. Identification fields and values: Document Type='Quote',No.='',Document Line No.='0',Line No.='10000') And I get this same error regardless what I set for the 4 PK fields... for example i send Document_Type='Order'... it still tells me the records exists for Document Type:'Quote'  .. it makes no sense.   I wonder if our disgruntled "partner" has done something in code to "prevent" us from solving our problems without "their  help"

Reply
vmanta responded on 12 Jun 2019 10:11 AM
My Badges
Verified Answer

Here's how I solved the problem (without paying partner / without dev licence):

1. There was no way to use "Notes" (without dev licence)

2. I chose to use Sales Order Comments, and set "Print on Pick Sheet" to TRUE...  and how I did this is below:

As per my comment above, simply creating a web service for Page 67 and attempting to create a Comment, was failing with error:

Error (OData): The Sales Comment Line already exists. Identification fields and values: Document Type='Quote',No.='',Document Line No.='0',Line No.='10000'

I was getting that error, regardless of the params passed...

I also noticed that *if* a manual comment was entered in NAV, and subsequently you would try to enter another comment via webservice - there was no error... but this observation didn't help me. I had a need to enter comments via web services, to new orders also entered via web services.

What i did - that solved this issue is to create a new Page of type "Card" for NAV Table 44 (Sales Comment Line) in "Microsoft Dynamics NAV Development Environment".

I gave it an object ID of 50081, named it SalesOrderComment, made it available as a web service...  

Now, using  ODATA to create comments with this new service, there are none of the issues I encountered above..

Note that although I'm able to create a PAGE, whenever I try to create or view any C/AL code or CodeUnit, I get permission error  (and I know we do not have dev licence). But we do have the "Microsoft Dynamics NAV Development Environment"   installed on the NAV server.

Hope this helps someone out there

Reply
vmanta responded on 12 Jun 2019 10:11 AM
My Badges
Verified Answer

Here's how I solved the problem (without paying partner / without dev licence):

1. There was no way to use "Notes" (without dev licence)

2. I chose to use Sales Order Comments, and set "Print on Pick Sheet" to TRUE...  and how I did this is below:

As per my comment above, simply creating a web service for Page 67 and attempting to create a Comment, was failing with error:

Error (OData): The Sales Comment Line already exists. Identification fields and values: Document Type='Quote',No.='',Document Line No.='0',Line No.='10000'

I was getting that error, regardless of the params passed...

I also noticed that *if* a manual comment was entered in NAV, and subsequently you would try to enter another comment via webservice - there was no error... but this observation didn't help me. I had a need to enter comments via web services, to new orders also entered via web services.

What i did - that solved this issue is to create a new Page of type "Card" for NAV Table 44 (Sales Comment Line) in "Microsoft Dynamics NAV Development Environment".

I gave it an object ID of 50081, named it SalesOrderComment, made it available as a web service...  

Now, using  ODATA to create comments with this new service, there are none of the issues I encountered above..

Note that although I'm able to create a PAGE, whenever I try to create or view any C/AL code or CodeUnit, I get permission error  (and I know we do not have dev licence). But we do have the "Microsoft Dynamics NAV Development Environment"   installed on the NAV server.

Hope this helps someone out there

Reply
I Gusti Made Ari Permadi responded on 11 Jun 2019 3:14 AM
My Badges
Suggested Answer

It is possible using SOAP, create a codeunit and write a function to write a note .

Tested working :

Publish the codeunit in Web Service :

Call in Postman :

Result in NAV :

Sample code :

[External] WriteSalesOrderNote(OrderNo : Code[20];Note : Text)
SalesHeader.GET(SalesHeader."Document Type"::Order,OrderNo);

RecordLink."Record ID" := SalesHeader.RECORDID;
RecordLink.Type := RecordLink.Type::Note;
TypeHelper.WriteRecordLinkNote(RecordLink,Note);
RecordLink.Created := CREATEDATETIME(TODAY,TIME);
RecordLink."User ID" := USERID;
RecordLink.Company := COMPANYNAME;
IF NOT RecordLink.INSERT THEN RecordLink.MODIFY;


Name	        DataType	Subtype	       Length
TypeHelper	Codeunit	Type Helper	
RecordLink	Record	        Record Link	
SalesHeader	Record	        Sales Header	


Reply

SBX - Two Col Forum

SBX - Migrated JS