Consume NAV Service – Get Item Picture

 

Hey Friends,

In my previous page I explained how to send Item picture over Web Service in a string, In this article I am gonna show how you can consume that service from C# side and show it to your Web application.

Below is the piece of code which you need to write, a bit of C# programming knowledge is needed and you are good to go.

In the E drive you will get the Image that is retrieved from NAV Side.

 

CHEERS!!

Item Picture- Webservice

 

Hey Friends,

I was just working on an assignment where I got the need of the customer like they want the Item Picture via web service. Another validation they put in was they don’t want the item picture to be saved on any particular directory instead they want on fly.

So now in standard NAV 2018 Item picture data-set has been changed from Blob to Mediaset so it was then added challenge. We need to convert the picture into streams and bytes and then we can send this over service but how to convert it into bytes. Converting Blob we all are well experienced but what about Mediaset.

There’s a new virtual table which Microsoft has introduced to maintain this identity in Blob which is Tenant Media. The reason why Microsoft did so is now we have the capability to add multiple pictures for an item.

So here is the piece of code how we are suppose to do this.

//RWN
Item.GET(ItemNo);
IF Item.Picture.COUNT = 0 THEN
EXIT(”);

TenantMedia.GET(Item.Picture.ITEM(1));
TenantMedia.CALCFIELDS(Content);
IF TenantMedia.Content.HASVALUE THEN BEGIN
CLEAR(PictureText);
CLEAR(PictureInStream);
TenantMedia.Content.CREATEINSTREAM(PictureInStream);
TempBlob.DELETEALL;
TempBlob.INIT;
TempBlob.Blob.CREATEOUTSTREAM(PicOutStream);
COPYSTREAM(PicOutStream,PictureInStream);
TempBlob.INSERT;
TempBlob.CALCFIELDS(Blob);
PictureText.ADDTEXT(TempBlob.ToBase64String);
END;
//RWN

Return this Picturetext in Web-service and they have to convert it from Base 64 string, they will have the real image.

Item Record Item
TenantMedia Record Tenant Media
PictureText BigText
PictureInStream InStream
TempBlob Record TempBlob

CHEERS

Permission Set – Security Filter

 

Hey Friends,

May be you all are aware about this feature in Permission Set which say Security Filter!! I just used and wanted to share this to you as this will add an extra security layer to your permission set. This basically works on field level, say you want to introduce one permission set and that permission should explicitly make the user to see only those records in Sales Order for which Salesperson code = SR,

Here’s how you can achieve this, Just navigate to Architectural Window./Departments/Administration/IT Administration/General/Permission Sets  and then hit permissions in the Action bar. Here you will find all set objects that has been introduced, just simply navigate to Sales Header and in the right side you will see security filters

 

Assist edit on this and then it will take you to new window which will give you the list of the Fields of that table and then you can apply your specific filter on any of the defined field.

 

Hit OK and you are done. Just apply this Role to any of the user and then cross verify!!

CHEERS

Soap Service – Special Characters

 

Hey Folks,

We all know SOAP Services has it’s own Protocol while commuting over different Platforms. Sometimes Client is willing to send special characters for there own reasons over web service but it is not permitted within SOAP protocols.

Here is the way how you can make this accessible with a tweak, while calling service replace this special characters with:

< is converted to &lt;

> is converted to &gt;

& is converted to &amp;

is converted to &quot;

Now at the other end you just need to decode it to get back the original special character that you have. Here is the code you need to write-

//RWN
Bigtext.ADDTEXT(DecodeSpecialCharacter.HtmlDecode(InputBigtext));
//RWN

Here Bigtext will have decoded value coming in InputBigtext.

DecodeSpecialCharacter    DotNet     System.Net.WebUtility.’System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

CHEERS

 

Debit Credit Concept – Accounting

 

Hey Friends,

I know there’s always been a confusion to understand this Accounting concept like which account gets Credited and exactly which will get Debited as there’s no generic sign for Debit and Credit. Sometimes Debit means Positive (+) and sometimes it means Negative (-) and the same goes vice versa for Credit. So I just made this small structure which will help you understand when Debit means positive and for which Account Type and the same for Credit.

 

 

 

 

 

 

Here Account Type means either its a Balance Sheet or Income Statement. Debit (+) means this Account will get Debited with a + value and Credit will be in -. The same way this will get Credited + means this Account will be Credited with a  + value and Debit will be in -.

I wrote DEALER on the top because it will make easier for you to remember the Accounts. First three DEA means Draw, Expense and Asset and last 3 LER means Liability, Equity and Revenue.

CHEERS

Disable Sorting – List Page

 

Hey Friends,

Recently I got a requirement where client asked me to disable Sorting. They don’t want any user to rearrange the data based on any field.  Here is just what needs to be done.

Open list page and navigate to Repeater Property –  Here you will find IndentationColumnName property. Just change it to 0 and we are done.

There are many properties in multiples places across NAV which we don’t bother to experience but it can literally make our life easier.

CHEERS

Cross Reference No – Item

 

Hey Friends,

There’s many features in standard NAV which we normally don’t use, not because we don’t want to but just because we are not aware. Item Cross Reference is one of the out of the box feature which I belief is rarely used by the end users but it’s really an awesome one for them to use in there day to day data entry process. The basic benefit of this is you don’t have to look for Item No every time, just your unique reference and it will automatically bring the respective item, Variant and so on.

So here’s what you need to do – Open Item List

Here as highlighted in screenshot you need to open Cross Reference and do the respective setup’s. This you need to do for each and every Item. So here we are doing for Item I000009.

Here you need to put the Customer No for the Customer’s you want to do along with the Variant and Unit of Measure Codes. Cross Ref No will be the key to identify this.

Now you need to navigate to Sales Order and you are supposed to make the new one.

Now as you see the screenshot we took the same customer for which we did the setup, Now we need to navigate to Line Items and push the drop down for Cross Reference No. Generally Cross Reference No is not visible so you need to choose it from Choose Columns. So once you hit the Drop Down you will have the list of Cross Reference’s that you did the setup for. Now you just have to hit OK and you will have your line item ready.

So by this you don’t have to look for your Item No every time. Just one setup as per your convenience and you are good to go.

CHEERS

File Upload – SFTP

 

Hey Friends,

This post I dedicated in how to upload a file on SFTP from NAV. This normally happens when we are doing some sort of processing from a file which has to be processed needs to be downloaded from a SFTP and then eventually needs to be processed. SFTP is Secured File Transfer Protocol so it’s  a level more secured then FTP.

Below is the screenshot of the code that needs to be written.

This code is to move File to respective SFTP.

WinSCP is free DLL that you can find over internet and its very effective.

CHEERS

File Upload – FTP

 

Hey Friends,

This post I dedicated in how to upload a file on FTP from NAV. This normally happens when we are doing some sort of processing from a file which has to be processed needs to be downloaded from a FTP and then eventually needs to be processed.

Below is the screenshot of the code that needs to be written.

This one is a very simple example, you can manipulate this as per your need. In the very next post I will come up on dealing with SFTP. This one will work only for FTP.

//RWN
ConnectionString := ‘ftp://your.ftp.address’;

SourceText := ‘Something that you want to write in the file’;

FTPRequest := FTPRequest.Create(ConnectionString);

FTPRequest.KeepAlive := TRUE;
FTPRequest.UseBinary := TRUE;
FTPRequest.Method := ‘STOR’;

FTPRequest.Credentials := NetworkCredential.NetworkCredential(‘UserID’,’Password’);

UTF8Encoding := UTF8Encoding.UTF8Encoding;

FTPRequest.ContentLength := UTF8Encoding.GetBytes(SourceText).Length;
RequestStream := FTPRequest.GetRequestStream;
RequestStream.Write(UTF8Encoding.GetBytes(SourceText),0,FTPRequest.ContentLength);
RequestStream.Close;

FTPResponse := FTPRequest.GetResponse;
MESSAGE(FTPResponse.StatusDescription);
//RWN

Variables

FTPRequest  DotNet System.Net.FtpWebRequest.’System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ FTPRequest DotNet System.Net.FtpWebRequest.’System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

FTPResponse DotNet System.Net.FtpWebResponse.’System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

NetworkCredential DotNet System.Net.NetworkCredential.’System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ WebRequestMethods DotNet System.Net.WebRequestMethods.’System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

UTF8Encoding DotNet System.Text.UTF8Encoding.’mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

RequestStream DotNet System.IO.Stream.’mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

ConnectionString Text

SourceText Text

CHEERS

 

 

Extended Text – Item Card

 

Hey Friends,

This page is all about How to Use Extended Text – Extended Text is a base functionality of Dynamics NAV where you can add some custom description for any of the Item which you want to Sell, Purchase etc..

So to use this you simply need to navigate to Item Card and open any of the Item, then and there on the Action Tab you will find a button Extended Text, you need to push this and a new page will open as shown in the below screenshot –

Highlighted part is the area where you need to fill in the text which you want to populate. Below is the Sales, Purchase and Service fast tab where you need to check the Flag where you exactly want this and disable the flags where you don’t.

Now try making a New Sales Order with the same Item for which you did the Setup –

Now as soon as you validate the Item, the Extended Text will automatically get populated as shown in the above screenshot. In the Item card you fill find a Flag Automatic Ext. Text. If this Flag is on then the text will automatically come otherwise you need to manually fill in by navigating to Function -> Insert Ext. Text.

CHEERS