Hi Folks -
I have a txt file named Newfilename.txt which 240 character of text something like this just 1 line in the file.
Customer no : 20000 Credit Limit : 10000 Tax area code : VA Date - 04/12/18 Location Code : 001 Department Code : 01
I am trying to write this to the Record link Notes table and I don't get any errors but the issue is that the entire text is not shown in the Notes it shows something like the below
Customer no : 20000 Credit Limit : 10000 Tax area code : VA
It drops the remaining text.
IntLen := MyFile.LEN;
WHILE (MyFile.POS < IntLen) DO BEGIN
Does anyone know what could the issue with the above function.
Any help is highly appreciated.
Why are you trying to read/write, why not just use COPYSTREAM?
Hi Erik -
I tried copystream too, COPYSTREAM(outstream,INSTREAM) what happens is say I have a string
Customer no. : 0001 Location Code : L1 Division code : 1234 Tax Area code : R001 Cust. Disc. Group : A001, everything works just fine but when I go to the Notes it just shows
Customer no. : 0001 Location Code : L1 Division code : 1234 and the remaining part of Tax area code : R001 and Cust. Disc. Group : A0001 is not there. I am just lost as to what am I missing. I have been scratching my head to resolve this issue, as you know If I go to a customer card and enter notes, I can enter tons of notes but when you update notes through a code, it just restricts to certain characters, not sure why.
That's strange, normally it takes the whole content. What is the code you are using with COPYSTREAM?
Don't open the file in writemode, if that doesn't work try without textmode (you just want to copy the whole content right?).
Hi Erik -
I tried your way too and still not luck. Below is the code for this task. Some code is remmed trying out all possible ways to get this working. Really..Really strange. Thanks again for all your help Erik.
In NewfileName which is called custinfo.txt below is the content
Customer no. : 0001 Location Code : L1 Division code : 1234 Tax Area code : R001 Cust. Disc. Group : A001
IF FileMgt.ServerFileExists(NewFileName) THEN BEGIN
RecRef.GETTABLE(CustRec); RecordLink.RESET; IF RecordLink.FIND('+') THEN LinkNo := RecordLink."Link ID" + 1 ELSE LinkNo := 1;
RecordLink.RESET; RecordLink.INIT; RecordLink."Link ID" := LinkNo; RecordLink."Record ID" := RecRef.RECORDID; RecordLink.URL1 := GETURL(CLIENTTYPE::Current, COMPANYNAME, OBJECTTYPE::Page, PAGE::"Customer Card"); RecordLink.Type := RecordLink.Type::Note; RecordLink.Created := CURRENTDATETIME; RecordLink."User ID":=USERID; RecordLink."To User ID" := GLSetup."CFO Email-ID"; RecordLink.Company:=COMPANYNAME; RecordLink.Notify := TRUE; NewFunction(RecordLink); RecordLink.INSERT;END;
LOCAL NewFunction(VAR RecordLink : Record "Record Link")RecordLink.Note.CREATEOUTSTREAM(StreamOutObj);
IntLen := MyFile.LEN;//WHILE (MyFile.POS < IntLen) DO BEGIN //MyFile.READ(s); StreamInObj.READ(s,MAXSTRLEN(s)); //COPYSTREAM(StreamOutObj,StreamInObj); StreamOutObj.WRITE(s,MAXSTRLEN(s)); //StreamInObj.READTEXT(s); //StreamOutObj.WRITETEXT(s,MAXSTRLEN(s));//END;
Is this the code you tested? The why do you have // before copystream?
You also have no create outstream!
This example is from Microsoft's own doc page. It copies a file to a file, but the principle is the same.
Thanks for your reply. Createoutstream is at the beginning of the function
Even I have seen the above code from Microsoft doc page and copying from file to file is not an issue works perfectly and I agree with you that the principle is the same but unfortunately it's not when it comes to copying from a file to the Notes of the record link. There is some character restriction when you copy the text from a file to Notes in the record link table.
Thanks again for all your help.
You are not supposed to use READ / WRITE.
Ok, agreed I will not use READ / WRITE, so the below should work correct or let me know if I am missing out something. Since I am writing to the Notes of record link. I have to use the createoutstream on record link. Still does not work. Chops off half of my text.
MyFile.OPEN(NewFileName); MyFile.CREATEINSTREAM(StreamInObj); RecordLink.Note.CREATEOUTSTREAM(StreamOutObj);COPYSTREAM(StreamOutObj,StreamInObj); MyFile.CLOSE();
Strange. You're sure that the file doesn't contain any controls to break it? And you remember to save the record link record?
Hi Erik - Really strange, I have tried just by creating a single line text in a file without any controls or break and in the record link I have INSERT command and like I said it's creating the text in the Notes of record link but not the entire text, if your text has 290 characters, In notes it just shows 140 characters of the text.
Having worked with NAV for the last 26 years, this is the first time NAV has stumped me. I have worked with Nav Since Avista till today's version and I have resolved any issues but this one issue just beats me.