Returning a Parameter when using webservices

attardc
Member Posts: 97
I'm using Dynamics NAV webservices to allow users to create contacts and related comments via a web interface.
Is there a way that when the Contact is created (when calling the Create Service through Visual Studio) NAV webservices return the Contact No. (which is assigned automatically with the NAV INSERT) to the Visual Studio application so that then they can save the comments linked to this contact No.?
Currently we have to create the contact, go to this newly created contact and then add the comments, in order to be able to have the Contact No. We would like to reduce this to a 1 step/1 screen process if necessary!
thanks in advance for your help!
regards
Christabel
Is there a way that when the Contact is created (when calling the Create Service through Visual Studio) NAV webservices return the Contact No. (which is assigned automatically with the NAV INSERT) to the Visual Studio application so that then they can save the comments linked to this contact No.?
Currently we have to create the contact, go to this newly created contact and then add the comments, in order to be able to have the Contact No. We would like to reduce this to a 1 step/1 screen process if necessary!
thanks in advance for your help!
regards
Christabel
0
Comments
-
Hi Christabel,
You receive automatically contact no. when calling "Create". Here is a simple example:string salesOrderNo = ""; SalesOrder so = new SalesOrder(); ClientHeadWs.Create(ref so); salesOrderNo = so.No;
0 -
With a published codeunit you can write a function to create both the contact and attach the comment or a note. You can place the comment in a bigtext variable. Here is an example of how you write the bigtext variable to the comment table or to a note.
LF[1] := 10; CASE SignSetup."Web Comment Stored" OF SignSetup."Web Comment Stored"::"In Comment Lines": WITH CommentLine DO BEGIN RESET; SETRANGE("Table ID",DATABASE::"SKYRR Signer Queue"); SETRANGE("Entry No.",Queue2."Entry No."); IF FINDLAST THEN NextLineNo := "Line No." + 10000 ELSE NextLineNo := 10000; INIT; "Table ID" := DATABASE::"SKYRR Signer Queue"; "Entry No." := Queue2."Entry No."; "Line No." := NextLineNo; Date := TODAY; BigComment.GETSUBTEXT(Comment,1,MAXSTRLEN(Comment)); IF STRPOS(Comment,LF) > 0 THEN BEGIN Comment := COPYSTR(Comment,1,STRPOS(Comment,LF) - 1); ReadPos := ReadPos + STRLEN(Comment) + 1; END ELSE BEGIN Tools.RepairLineEnd(Comment); ReadPos := ReadPos + STRLEN(Comment); END; "User ID" := CurrentUserID; INSERT; NextLineNo := NextLineNo + 10000; Date := 0D; WHILE BigComment.LENGTH > ReadPos DO BEGIN "Line No." := NextLineNo; BigComment.GETSUBTEXT(Comment,ReadPos + 1,MAXSTRLEN(Comment)); IF STRPOS(Comment,LF) > 0 THEN BEGIN Comment := COPYSTR(Comment,1,STRPOS(Comment,LF) - 1); ReadPos := ReadPos + STRLEN(Comment) + 1; END ELSE BEGIN Tools.RepairLineEnd(Comment); ReadPos := ReadPos + STRLEN(Comment); END; INSERT; NextLineNo := NextLineNo + 10000; END; END; SignSetup."Web Comment Stored"::"In Fact Box Notes": BEGIN ServerTempFileName := ThreeTierMgt.ServerTempFileName('',''); StreamWriter := ServerFile.CreateText(ServerTempFileName); ReadPos := 0; WHILE ReadPos < BigComment.LENGTH DO BEGIN BigComment.GETSUBTEXT(CommentText,ReadPos + 1,MAXSTRLEN(CommentText)); ReadPos := ReadPos + STRLEN(CommentText); StreamWriter.Write(CommentText); END; StreamWriter.Close; RecordLink.GET(Queue2.ADDLINK('',Queue2.TABLECAPTION)); RecordLink.Type := RecordLink.Type::Note; RecordLink."User ID" := CurrentUserID; RecordLink.Note.CREATEOUTSTREAM(OutStr); Encoding := Encoding.UTF8; BinaryWriter := BinaryWriter.BinaryWriter(OutStr,Encoding); BinaryWriter.Write(ServerFile.ReadAllText(ServerTempFileName)); RecordLink.MODIFY; ServerFile.Delete(ServerTempFileName); END; END;
and the RepariLineEnd isRepairLineEnd(VAR inpara : Text[1024]) UsedStringLength : Integer IF STRPOS(inpara,' ') > 0 THEN WHILE COPYSTR(inpara,STRLEN(inpara),1) <> ' ' DO inpara := COPYSTR(inpara,1,STRLEN(inpara) - 1);
________________________________
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com0 -
Or if you want to import complex data you can use importing by passing a XmlPort into a function of the codeunit. You have to implicitly call import and later filter exported data. As this XmlPort data structure appears in .NET as a class with subclasses this method seems to be really powerful (you can send all data in one transaction, after processing the data they can be simply sent back in a actualized form). Try to import complex data in this way.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions