Page 1 of 1

How to get custom fields and their values from a plugin

PostPosted: Tue Jun 20, 2017 7:32 pm
by jak
Hi,

I have created a plugin in jiwa previously, now i'm creating a new plugin in jiwa.
In this Plugin i want to export the fields and their data of previous plugin. Can you please let me know how can i get the fields and their values of a plugin using plugin RecID?

Also I want to insert data in those fields as well, can you please let me know this as well?

Thank you in advance

Re: How to get custom fields and their values from a plugin

PostPosted: Wed Jun 21, 2017 8:49 am
by Scott.Pearce
On the "Custom Fields" tab of the original plugin, use the "Move" button next to the custom field definition to move the fields and their values to the new plugin.

Re: How to get custom fields and their values from a plugin

PostPosted: Thu Jun 22, 2017 4:04 pm
by jak
Hi Scott,

i'm working on new plugin to get data from previously created plugin custom fields, can you please tell me the code which i can add in my developing plugin to get data of custom fields of previously created plugin?

I try to get fields of Jiwa Business Logic classes
JiwaApplication.CustomFields.CustomFieldValue

and

JiwaApplication.Plugin.Plugin

but wasn't get any success as yet, I want to get custom fields of a plugin and data of that fields by using code in newly created plugin?
Can you please help me with it.

Thank you in advance

Re: How to get custom fields and their values from a plugin

PostPosted: Thu Jun 22, 2017 5:11 pm
by Mike.Sheen
Try this:

C#:
Code: Select all
var customFieldValue = debtor.CustomFieldValues.get_ItemFromSettingName("CustomFieldName", "PluginName");
System.Diagnostics.Debug.WriteLine(customFieldValue.Contents); // examine value
customFieldValue.Contents = "x"; // set value


VB:
Code: Select all
Dim customFieldValue as JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue = debtor.CustomFieldValues.ItemFromSettingName("CustomFieldName", "PluginName")
System.Diagnostics.Debug.WriteLine(customFieldValue.Contents) ' examine value
customFieldValue.Contents = "x" ' set value


replace debtor with the object instance you're using.

The ItemFromSettingName method is overloaded - so you can either provide both the CustomFieldName and PluginName as shown above, or just the CustomFieldName if you're sure no other plugin will have a custom field of the same name.

Re: How to get custom fields and their values from a plugin

PostPosted: Thu Jun 22, 2017 6:16 pm
by jak
Hi!

Thanks for your reply.
I have try this
Code: Select all
var customFieldValue = jobtask.CustomFieldValues.get_ItemFromSettingName("Debtor No", "Debtor Plugin");


but it says

Code: Select all
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

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

Source Error:


Line 133:            */
Line 134:
Line 135:            var customFieldValue = jobtask.CustomFieldValues.get_ItemFromSettingName("Debtor No", "Debtor Plugin");



can you please help me with this.

Thank you in advance

Re: How to get custom fields and their values from a plugin

PostPosted: Thu Jun 22, 2017 8:11 pm
by Mike.Sheen
jak wrote:I have try this
Code: Select all
var customFieldValue = jobtask.CustomFieldValues.get_ItemFromSettingName("Debtor No", "Debtor Plugin");


Do you have a plugin named "Debtor Plugin" and does that plugin have a custom field with a name of "Debtor No" ?

Re: How to get custom fields and their values from a plugin

PostPosted: Thu Jun 22, 2017 8:17 pm
by jak
yes, I have created that plugin before.

Re: How to get custom fields and their values from a plugin  Topic is solved

PostPosted: Thu Jun 22, 2017 10:00 pm
by Mike.Sheen
I created a plugin named "Debtor Plugin1" and added a custom field "Debtor No" - then I added some code to write to the debug output the value of the custom field whenever a debtor is read - and I didn't get the error, and I saw the output in my debug console.

I've attached the plugin (for version 7.00.175.00) - try that out and see if you have any problems with that.

Mike