Work Order Instruction custom field

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Work Order Instruction custom field

Postby DannyC » Thu Oct 07, 2021 2:50 pm

I'm adding a work order instruction custom field. It's a simple lookup to select a PartNo using jswInventory.

My problem is when doing
Code: Select all
CustomFieldValue.Contents = MyValue
it's throwing an object reference not set to an instance of an object. Debugging I can see that CustomFieldValue is null.
Shouldn't that be passed in as a parameter to the ButtonClicked event in the plugin?
Is there another way I can get CustomFieldValue to set the contents?
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Work Order Instruction custom field

Postby Mike.Sheen » Thu Oct 07, 2021 3:04 pm

I added a custom field of type lookup to Work Order instructions and didn't get any such error.

Attached is the plugin I used. It was in Jiwa version 7.2.1 SR5 (why does nobody tell us the version?)

Take a look and see if you can work out why you get an error and my plugin doesn't.

If you still can't work it out, then provide a sample plugin which exhibits the problem (another thing nobody seems to do!).
Attachments
Plugin Work Order Instruction Custom Field Example.xml
(32.31 KiB) Downloaded 546 times
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Work Order Instruction custom field

Postby DannyC » Thu Oct 07, 2021 3:18 pm

(why does nobody tell us the version?)

Because if there's a latest version (and there's always a latest version) why mention it? I'd assume your own dev environment would be patched to the latest. If it's me who's writing a plugin for an older version and ask I question via these forums, I'll mention the version as it's more relevant.

provide a sample plugin which exhibits the problem (another thing nobody seems to do!)

Because often the plugin contain client-identifying information or other confidential information and to strip out that irrelevant code is just more trouble than it's worth and wouldn't contribute to the question in point.

But seeing as you've asked, this is my ButtonClicked code (the relevant bit!). Still not sure why my code is getting a null for CustomFieldValue but I'll replace the code below with yours.
Code: Select all
    public void ButtonClicked(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic BusinessLogicHost, JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid GridObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm FormObject, int Col, int Row, JiwaFinancials.Jiwa.JiwaApplication.IJiwaLineCustomFieldValues HostItem, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomField CustomField, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue CustomFieldValue)
    {
      if (CustomField.PluginCustomField.Name == "Extra1")
      {
         var search = FormObject.Manager.Search;   
         search.Clear();
         search.CurrentOption = 1;
         JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch.SearchModes searchMode = JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswInventory;
         search.SetDefaultSearch(ref searchMode);
         search.UsePinBoard = false;      
            
         if (search.Show(FormObject.Form) == System.Windows.Forms.DialogResult.OK)
         {
               if (search.Results.Count > 0)
               {
                  var idField = (JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)search.get_Fields(2);
                  //MessageBox.Show(idField.FieldValue.ToString());
                  //System.Diagnostics.Debugger.Launch();
                  
                  CustomFieldValue.Contents = idField.FieldValue.ToString();
                   //CustomFieldValue.DisplayContents = string.Format("{0}", idField.FieldValue.ToString());
               }
               else
               {
                  throw new JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException();
               }
         }
         else
            {
            throw new JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException();
            }
      }      
    }
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Work Order Instruction custom field

Postby Mike.Sheen » Thu Oct 07, 2021 3:21 pm

DannyC wrote: to strip out that irrelevant code is just more trouble than it's worth


Wow.
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Work Order Instruction custom field

Postby Scott.Pearce » Thu Oct 07, 2021 3:23 pm

I don't see the line you said is giving the error:

Code: Select all
CustomFieldValue.Contents = MyValue


in your code anywhere:

Code: Select all
 public void ButtonClicked(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic BusinessLogicHost, JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid GridObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm FormObject, int Col, int Row, JiwaFinancials.Jiwa.JiwaApplication.IJiwaLineCustomFieldValues HostItem, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomField CustomField, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue CustomFieldValue)
    {
      if (CustomField.PluginCustomField.Name == "Extra1")
      {
         var search = FormObject.Manager.Search;   
         search.Clear();
         search.CurrentOption = 1;
         JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch.SearchModes searchMode = JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswInventory;
         search.SetDefaultSearch(ref searchMode);
         search.UsePinBoard = false;     
           
         if (search.Show(FormObject.Form) == System.Windows.Forms.DialogResult.OK)
         {
               if (search.Results.Count > 0)
               {
                  var idField = (JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)search.get_Fields(2);
                  //MessageBox.Show(idField.FieldValue.ToString());
                  //System.Diagnostics.Debugger.Launch();
                 
                  CustomFieldValue.Contents = idField.FieldValue.ToString();
                   //CustomFieldValue.DisplayContents = string.Format("{0}", idField.FieldValue.ToString());
               }
               else
               {
                  throw new JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException();
               }
         }
         else
            {
            throw new JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException();
            }
      }     
    }
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Work Order Instruction custom field

Postby DannyC » Thu Oct 07, 2021 3:36 pm

Well, even replacing your code with mine still comes up with the same error.

Here's a screenshot of your code, debugging in Visual Studio. You can see the value for CustomFieldValue is null.

Plugin in VS.png
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Work Order Instruction custom field

Postby DannyC » Thu Oct 07, 2021 3:41 pm

I don't see the line you said is giving the error:


Code: Select all
CustomFieldValue.Contents = idField.FieldValue.ToString();


Sure, it's not
Code: Select all
CustomFieldValue.Contents = MyValue;
but the issue isn't the value getting passed in, it's that the CustomFieldValue is null.
Last edited by DannyC on Thu Oct 07, 2021 3:42 pm, edited 1 time in total.
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Work Order Instruction custom field

Postby Mike.Sheen » Thu Oct 07, 2021 3:42 pm

Danny,

I'm afraid this is the next step for you:
If you still can't work it out, then provide a sample plugin which exhibits the problem


I've gone to the trouble of trying to reproduce your issue and creating a plugin specifically to try and reproduce your issue - the least you can do now is reciprocate and provide a plugin which demonstrates the problem.
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Work Order Instruction custom field

Postby Scott.Pearce » Thu Oct 07, 2021 3:42 pm

Code: Select all
CustomFieldValue.Contents = idField.FieldValue.ToString();


Oh, well in that case idField is likely null.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Work Order Instruction custom field

Postby DannyC » Thu Oct 07, 2021 3:49 pm

the least you can do now is reciprocate and provide a plugin which demonstrates the problem

We seem to be having an argument but not sure why. I'm just trying to give all relevant information succinctly without distracting with irrelevant information.

Attached is my plugin. And it's 7.2.1 SR5.
Attachments
Plugin Work order custom field.xml
(31.29 KiB) Downloaded 899 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest