Displaying Unit of Measure in sales order line  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Displaying Unit of Measure in sales order line

Postby DannyC » Thu May 21, 2020 1:14 pm

I just want to get whatever UOM has been selected on a sales order line.

As an intial check I am just displaying a messagebox to confirm I'm getting the right UOM.
Code: Select all
MessageBox.Show(line.UnitOfMeasure.Name);


But I am getting an error 'object reference not set to an instance of an object.'
What am I doing wrong?
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29

Re: Displaying Unit of Measure in sales order line

Postby Mike.Sheen » Thu May 21, 2020 1:31 pm

That property is nullable, so you need to check if it is null before using it.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Displaying Unit of Measure in sales order line  Topic is solved

Postby Scott.Pearce » Thu May 21, 2020 1:36 pm

A null (or nothing) UnitOfMeasure property means that "units" is used.

Code: Select all
if(line.UnitOfMeasure == null)
    MessageBox.Show(line.Units);
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Displaying Unit of Measure in sales order line

Postby DannyC » Thu May 21, 2020 2:24 pm

Another successful forum thread!
Thanks Mike & Scott.

This is what I did to get it working
Code: Select all
if(line.UnitOfMeasure == null)
{
    MessageBox.Show(line.Units);
}
else
{
    MessageBox.Show(line.UnitOfMeasure.Name);
}
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 5 guests

cron