Debtor Import - importing Custom Settings  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Debtor Import - importing Custom Settings

Postby neil.interactit » Thu Jan 19, 2023 10:19 am

Hey guys,

I have a requirement to populate some custom settings when importing records via Debtor Import.

I haven't been able to nail this. Adapting from viewtopic.php?f=26&t=1674 I wasn't able to get DestinationProperties.ReadEnd to even fire, and at the Imported event, I could not spot where in the DebtorImport object to access and process additional data.

Would you be able to provide a small sample plugin to get me started?

Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Debtor Import - importing Custom Settings

Postby Mike.Sheen » Thu Jan 19, 2023 12:29 pm

neil.interactit wrote:Hey guys,

I have a requirement to populate some custom settings when importing records via Debtor Import.

I haven't been able to nail this. Adapting from viewtopic.php?f=26&t=1674 I wasn't able to get DestinationProperties.ReadEnd to even fire, and at the Imported event, I could not spot where in the DebtorImport object to access and process additional data.

Would you be able to provide a small sample plugin to get me started?

Cheers,
Neil.


Custom fields are supported out of the box for debtor imports.

You'll see the custom fields at the bottom of the drop-down combo when mapping source to the destination column.

DebtorImportCustomFields.png


We'll auto-map if we find a column in the CSV with a header matching the custom field name.
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Debtor Import - importing Custom Settings

Postby neil.interactit » Thu Jan 19, 2023 1:41 pm

Thanks Mike.

My bad for not being specific ... there is some custom logic also required (if no value supplied, auto generate and assign a new value). So I was hoping to intercept via a plugin to be able to achieve this.

Cheers,
Neil
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Debtor Import - importing Custom Settings

Postby SBarnes » Thu Jan 19, 2023 3:30 pm

Try reading this post where Mike suggested how to do it for inventory, it should work the same.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Debtor Import - importing Custom Settings

Postby neil.interactit » Thu Jan 19, 2023 3:57 pm

Thanks Stuart, yes I tried that, but no joy ... I wasn't able to get DestinationProperties.ReadEnd to fire in the debtor import scenario.
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Debtor Import - importing Custom Settings  Topic is solved

Postby SBarnes » Thu Jan 19, 2023 4:15 pm

What service release are you on this could be your problem if you are not on SR5 or greater.

Post the plugin that you have might help as this might also
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Debtor Import - importing Custom Settings

Postby neil.interactit » Fri Jan 20, 2023 2:15 pm

Thanks Stuart.

That helped. I adapted your (final) sample to provide the functionality needed.

Mike, fyi, using Stuart's final sample in SR13 here, the BusinessLogicPlugin section appears not to fire (no "would have been set by this" MessageBox from there).

In case it helps others, here is the code to allow a Custom Field Value to be set algorithmically during the Debtor Import process ...

Code: Select all
using JiwaFinancials.Jiwa.JiwaDebtors;
using JiwaFinancials.Jiwa.JiwaDebtors.Import;
using JiwaFinancials.Jiwa.JiwaDebtorsUI.Import;

namespace DebtorImportBPayCRN
{
    #region "FormPlugin"
    public class FormPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaFormPlugin
    {
        public override object InitializeLifetimeService()
        {
            // returning null here will prevent the lease manager
            // from deleting the Object.
            return null;
        }
        public void SetupBeforeHandlers(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
        {
            var form = JiwaForm as MainForm;
            if (form == null) return;
            Helper.Manager = JiwaForm.Manager;
            form.BrowseUltraButton.Click += delegate { SetBpayCrn(form.DebtorImportObject.DestinationProperties); };
        }
        public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
        {
        }
        public void SetBpayCrn(DestinationPropertyCollection destinationPropertyCollection)
        {
            destinationPropertyCollection["Debtor.AccountNo"].SetterMethod = delegate (Debtor debtor, string value, string rowData, string[] row, int rowNo, Mapping mapping)
            {
                debtor.AccountNo = value;
                var bpayCrn = debtor.CustomFieldValues.get_ItemFromSettingName("BpayCrn");
                if (string.IsNullOrEmpty(bpayCrn.Contents)) bpayCrn.Contents = NextBpayCrn();
            };
        }
    }
    #endregion
}


Cheers,
Neil
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Debtor Import - importing Custom Settings

Postby Mike.Sheen » Fri Jan 20, 2023 2:40 pm

neil.interactit wrote:Mike, fyi, using Stuart's final sample in SR13 here, the BusinessLogicPlugin section appears not to fire (no "would have been set by this" MessageBox from there).


That sounds like a problem with Stuarts plugin - you should engage the author to address that :)

I'm not sure if you're reporting an issue now or not... If the code you have shown works, then that indicates that the import works as intended.
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Debtor Import - importing Custom Settings

Postby SBarnes » Fri Jan 20, 2023 2:45 pm

That sounds like a problem with Stuarts plugin - you should engage the author to address that :)



hqdefault.jpg
hqdefault.jpg (20.16 KiB) Viewed 918 times
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Debtor Import - importing Custom Settings

Postby Mike.Sheen » Fri Jan 20, 2023 2:47 pm

NO GOOD DEED GOES UNPUNISHED
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 41 guests

cron