Add data to plugin and document type.  Topic is solved

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

Add data to plugin and document type.

Postby nexio » Mon Jun 19, 2017 10:11 pm

Hi,

The external application we are developing in ASP.NET (C#) has to add data in Jiwa which will be shown through a plugin. We have tried the plugin, customfields and customfieldcollection.

We also have to set the document type as Image, but it is not setting it in DocumentType (This is not part of the plugin, the document in service manager job task).


If anyone can help us locate how to add data through the classes, it would help a lot with the application.

Thanks
nexio
Occasional Contributor
Occasional Contributor
 
Posts: 24
Joined: Thu Jun 08, 2017 6:32 pm

Re: Add data to plugin and document type.

Postby Mike.Sheen » Mon Jun 19, 2017 10:50 pm

nexio wrote:Hi,

The external application we are developing in ASP.NET (C#) has to add data in Jiwa which will be shown through a plugin. We have tried the plugin, customfields and customfieldcollection.

We also have to set the document type as Image, but it is not setting it in DocumentType (This is not part of the plugin, the document in service manager job task).


If anyone can help us locate how to add data through the classes, it would help a lot with the application.

Thanks


Hi Nexio,

I'm not real clear on what it is you are trying to do. If you want to add a custom field, then you should not do that via an external application - a plugin should be created using the Jiwa application which adds the field to the plugin.
CustomField.png
Screenshot - plugin maintenance add custom field


As for your adding of a document of type Image - you can add documents via an external application, and the Document Type just needs to be set appropriately - can you show your code on how you are adding a document to a Service Manager task?

Mike
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: Add data to plugin and document type.

Postby nexio » Mon Jun 19, 2017 11:21 pm

Hi Mike,

Thanks for replying.

Sorry for the confusion, there is already a custom plugin we have created in Jiwa for adding custom fields, and we have to send the data to that plugin so that it can update Jiwa. The plugin will save and display the item which is mentioned in service manager and Invoice Number. We have to get the plugin name, and plugin custom fields name that we have created in it and how to send the data to them.
Code: Select all
            JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin plugin = new JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin();
            plugin.Read("Plugin RecID as in SY_Plugin table");

Can you please let us know how to get the custom plugin name and its fields name and how can we populate the data in those fields?

For Document :
Code: Select all
JiwaFinancials.Jiwa.JiwaApplication.Documents.Document jobdocument = new JiwaFinancials.Jiwa.JiwaApplication.Documents.Document();
jobdocument.FileBinary = FileUploadBox.FileBytes;
jobdocument.PhysicalFileName = FileUploadBox.FileName;
jobdocument.Description = "File Description";
jobdocument.DocumentType ...


Not Sure what to do after this, we have tried jobdocument.DocumentType.Description and also tried creating a different object.
This is uploading the file in the job, with file description, but it does not set it to image Document Type.

My question is, that how can we get the document type which are present in Jiwa (like Image, Document, Others)?

Thanks
nexio
Occasional Contributor
Occasional Contributor
 
Posts: 24
Joined: Thu Jun 08, 2017 6:32 pm

Re: Add data to plugin and document type.  Topic is solved

Postby Mike.Sheen » Thu Jun 22, 2017 5:20 pm

nexio wrote:Can you please let us know how to get the custom plugin name and its fields name and how can we populate the data in those fields?


Have a look at this forum post - it shows how to get and set custom field values.

You should know the plugin name, as the Setup methods of the plugin pass an instance of the Plugin class as a parameter - and that has the plugin name as a property.

nexio wrote:For Document :
Code: Select all
JiwaFinancials.Jiwa.JiwaApplication.Documents.Document jobdocument = new JiwaFinancials.Jiwa.JiwaApplication.Documents.Document();
jobdocument.FileBinary = FileUploadBox.FileBytes;
jobdocument.PhysicalFileName = FileUploadBox.FileName;
jobdocument.Description = "File Description";
jobdocument.DocumentType ...


Not Sure what to do after this, we have tried jobdocument.DocumentType.Description and also tried creating a different object.
This is uploading the file in the job, with file description, but it does not set it to image Document Type.

My question is, that how can we get the document type which are present in Jiwa (like Image, Document, Others)?

Thanks


There is a collection in the business logic objects. That list changes, depending on which object you're using. In the case of Service Manager Jobs, there is a property named Documents and that Documents property has a property named DocumentTypes - that's the list of valid document types for service jobs.
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: Add data to plugin and document type.

Postby nexio » Sat Jun 24, 2017 11:28 pm

Hi Mike,

Thanks for your reply. We have added the documents type.

But when we add custom fields, we get the null reference error:

System.NullReferenceException: Object reference not set to an instance of an object.


I searched in the forum, found few other posts which were also getting same error, tried their solutions, but nothing has worked so far in adding custom field values.

We have to add the custom fields while adding a task in service manager job, but it gives the null reference error in the first line:

Code: Select all
var cfv = smjobtaskobj.CustomFieldValues.get_ItemFromSettingName("InvoiceNumber", "PluginName");
cfv.Contents = "NewInvoiceNo";


But then we tried with debtor and salesorder objects (as mentioned in the posts found on forum), using that same error is pointing to second line where we add the contents.
Code: Select all
var cfv = salesorderobj.CustomFieldValues.get_ItemFromSettingName("InvoiceNumber", "PluginName");
cfv.Contents = "NewInvoiceNo";


Also tried creating new object from JiwaApplication.CustomFields.CustomFieldValue but that also results in same error.

It might be because we are creating a new job and a task in service manager, and salesorder and debtor are already created, so we tried a different approach (found in a post in the forum)

Code: Select all
foreach (JiwaApplication.CustomFields.CustomFieldValue customFieldValue in salesorderobj.CustomFieldValues)
            {
                if (customFieldValue.CustomField.PluginCustomField.Name == "InvoiceNumber")               
                {
                    customFieldValue.Contents = "newinvoiceno";
                }
            }


This does not give any error, but it does not add in custom fields either.

I have checked and verified the Plugin name and Custom Field Name, both are correct. Even tried with get item from settingID, but still same error.

It is required that we put invoice number and other fields from invoice, like part number in the custom fields.

Sorry for the long post. But we really need help with this one.

Thanks
nexio
Occasional Contributor
Occasional Contributor
 
Posts: 24
Joined: Thu Jun 08, 2017 6:32 pm

Re: Add data to plugin and document type.

Postby SBarnes » Sun Jun 25, 2017 9:59 am

Hi Nexio

The code below works for me on the sales order line if this of any help

Code: Select all
line.CustomFieldValues.get_ItemFromSettingName("ConsolidateHistText").Contents += " ( Moved to " + neworder.InvoiceID + " )";
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Add data to plugin and document type.

Postby Mike.Sheen » Mon Jun 26, 2017 9:07 am

nexio wrote:We have to add the custom fields while adding a task in service manager job, but it gives the null reference error in the first line:

Code: Select all
var cfv = smjobtaskobj.CustomFieldValues.get_ItemFromSettingName("InvoiceNumber", "PluginName");
cfv.Contents = "NewInvoiceNo";



This means there is no plugin called "PluginName", or if there is - it does not contain a custom field named "InvoiceNumber" - or perhaps smjobtaskobj is null - I don't know without a sample application showing the issue.

It should be really easy for you to provide a plugin, and a sample application that demonstrates your issue.

1. Create a new plugin
2. Add a custom field to the Service tasks module of the plugin
3. create a console application to logon, create or read a service job and then set the contents of the custom field
4. Test the console application - does the error occur? If yes, then provide the plugin and console application as attachments to a forum post.
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: Add data to plugin and document type.

Postby nexio » Fri Jun 30, 2017 11:44 pm

Hi,

Thanks for your help guys, we finally were able to send data to the plugin.

The code which worked:
Code: Select all
//Create the task and add it in the job before loop.
foreach (JiwaFinancials.Jiwa.JiwaServiceManager.Task s_task in sm_job.Tasks)
{
    var pluginfieldvalue = s_task.CustomFieldValues.get_ItemFromSettingName("PluginFieldName", "PluginName");
    pluginfieldvalue.Contents = "string";
}


It was not working because we were trying to add custom field without adding the task in the job, we added the task in job and then the loop and it worked. once it stopped throwing null exceptions, we tried to add content we wanted to be displayed in Jiwa, for eg. in the custom fields invoice number was required, so we directly added invoice number as pluginfieldvalue.Contents, but it showed nothing in Jiwa. What it really required was InvoiceID, once we added InvoiceID instead of Invoice number, it showed up. And in similar fashion all other required contents were added.

Thanks
nexio
Occasional Contributor
Occasional Contributor
 
Posts: 24
Joined: Thu Jun 08, 2017 6:32 pm

Re: Add data to plugin and document type.

Postby nexio » Sat Jul 01, 2017 10:57 pm

Hi,

I guess I spoke too soon, although it is working on development machine (with Visual Studio 2017 and IIS Express 10 and .NET 4.7), but it does not work on target machine when hosted on IIS 7.0 on 2008 R2 64bit with .NET 4.7 .

As soon as we remove the code in the loop (mentioned below), it works in the the target machine too.

We did some digging in the error and now it is throwing null exceptions in the foreach loop in the target machine.

Code: Select all
foreach (JiwaFinancials.Jiwa.JiwaServiceManager.Task s_task in sm_job.Tasks)
{
    var pluginfieldvalue = s_task.CustomFieldValues.get_ItemFromSettingName("PluginFieldName", "PluginName");
    pluginfieldvalue.Contents = "string";
}
nexio
Occasional Contributor
Occasional Contributor
 
Posts: 24
Joined: Thu Jun 08, 2017 6:32 pm

Re: Add data to plugin and document type.

Postby SBarnes » Sat Jul 01, 2017 11:11 pm

Hi Nexio,

The only immediate things that spring to mind from previously using Jiwa and IIS in an ASP.net application is make sure that you have enabled 32 bit support on the on the application pool and that all the Jiwa DLLs are in the Bin directory for the site. You can always try compiling for the 32 bit target as well and have a look at what user account the application pool is running under also as it could be permission related.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron