Page 1 of 2

new quote alert after insertion via API

PostPosted: Sat Feb 25, 2023 9:10 am
by JuiceyBrucey
After I insert a new quote via the API, I would like some sort of alert, popup, or other attention getting alert, that tells the JIWA user that there is a new order pending.
Is there any such thing in JIWA?
I have tried inserting quotes manually etc, but there does not seem to be any thing like an alert to get the attention of the JIWA user.
Thank you.
Cheers

Re: new quote alert after insertion via API

PostPosted: Mon Feb 27, 2023 12:00 pm
by Mike.Sheen
JuiceyBrucey wrote:After I insert a new quote via the API, I would like some sort of alert, popup, or other attention getting alert, that tells the JIWA user that there is a new order pending.
Is there any such thing in JIWA?
I have tried inserting quotes manually etc, but there does not seem to be any thing like an alert to get the attention of the JIWA user.
Thank you.
Cheers


ToDo's in Jiwa will cause a toast notification to appear.

You can very simply in a plugin handle the quote's business logic save end handler and create a to-do.

Re: new quote alert after insertion via API

PostPosted: Mon Feb 27, 2023 1:26 pm
by JuiceyBrucey
Thank you for your reply.
Is there any tutorials related to this topic?
I have had a look and cant find anything yet.

Do the ToDo notes go into the IN_Notes table?
Thank you.
Cheers

Re: new quote alert after insertion via API

PostPosted: Mon Feb 27, 2023 1:44 pm
by JuiceyBrucey
Found the tutorial. I will get back to you if I need help.
Thanks again

Re: new quote alert after insertion via API

PostPosted: Mon Feb 27, 2023 3:37 pm
by SBarnes
Creating a to do is not hard the code below for example will do this, but to fire off when a quote is added is a bit more involved, in this case unless you have .net programming experience and are fairly familiar with Jiwa it may be better to ask Jiwa for a quote to provide the functionality.


Code: Select all
 public static void SendInternalMessage(Manager manager, List<string> toList, string subject, string body)
        {
            foreach (string usr in toList)
            {
                JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo toDo = manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo>(null);
                toDo.CreateNew();
                toDo.AssignedTo.ReadRecordByUsername(usr);
                toDo.Subject = subject;

                toDo.Body = body;



                toDo.ReminderPredefinedSetting = JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo.ReminderPredefinedSettingType.WhenDue;
                toDo.ReminderSpecificDateTime = DateTime.Now;
                toDo.ReminderEnabled = true;
                toDo.Save();
            }
        }

Re: new quote alert after insertion via API

PostPosted: Mon Feb 27, 2023 3:47 pm
by JuiceyBrucey
Mike.Sheen wrote:
JuiceyBrucey wrote:After I insert a new quote via the API, I would like some sort of alert, popup, or other attention getting alert, that tells the JIWA user that there is a new order pending.
Is there any such thing in JIWA?
I have tried inserting quotes manually etc, but there does not seem to be any thing like an alert to get the attention of the JIWA user.
Thank you.
Cheers


ToDo's in Jiwa will cause a toast notification to appear.

You can very simply in a plugin handle the quote's business logic save end handler and create a to-do.


Is there any examples of this that I can follow?
I have found the database table that the ToDos exist in and manually inserted one, but I cannot get any notification to pop up.
I have modified the reminder date via SQL to try it out, but nothing yet.
Any advice would be great.
thank you.

Re: new quote alert after insertion via API

PostPosted: Mon Feb 27, 2023 3:52 pm
by SBarnes
Go to system settings -> system configuration -> system and put a value in the poling interval setting then log out and back in but you shouldn't be adding to the tables directly via sql, you should use the Jiwa objects as in the code I posted.

Re: new quote alert after insertion via API

PostPosted: Mon Feb 27, 2023 6:35 pm
by JuiceyBrucey
SBarnes wrote:Creating a to do is not hard the code below for example will do this, but to fire off when a quote is added is a bit more involved, in this case unless you have .net programming experience and are fairly familiar with Jiwa it may be better to ask Jiwa for a quote to provide the functionality.


Code: Select all
 public static void SendInternalMessage(Manager manager, List<string> toList, string subject, string body)
        {
            foreach (string usr in toList)
            {
                JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo toDo = manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo>(null);
                toDo.CreateNew();
                toDo.AssignedTo.ReadRecordByUsername(usr);
                toDo.Subject = subject;

                toDo.Body = body;



                toDo.ReminderPredefinedSetting = JiwaFinancials.Jiwa.JiwaApplication.JiwaToDos.ToDo.ReminderPredefinedSettingType.WhenDue;
                toDo.ReminderSpecificDateTime = DateTime.Now;
                toDo.ReminderEnabled = true;
                toDo.Save();
            }
        }


I am close to making a variation of this work but I cannot access the Manager class.
How would I do that?
I usually code in PHP etc, but I am learning C# while I am doing this. I am doing tutorials etc all day. So I wont be asking dumb questions forever. But I need to get past this issue ASAP and your help is much appreciated.
thank you.

Re: new quote alert after insertion via API  Topic is solved

PostPosted: Mon Feb 27, 2023 6:50 pm
by Mike.Sheen
JuiceyBrucey wrote:I am close to making a variation of this work but I cannot access the Manager class.
How would I do that?


It's a property of all our business logic objects, forms, items, collections.

If you are coding inside a plugin, it's also accessible via the passed Plugin parameter of most plugin entry point methods (eg: Setup)

Attached is a plugin which creates a Todo whenever a quote is created, and assigns it to the "Admin" user.

Re: new quote alert after insertion via API

PostPosted: Mon Feb 27, 2023 6:51 pm
by SBarnes
If you have created a plugin to include the code which is I what I have assume you have done then the setup methods get handed a plugin which has a manager as a property as do the Business host / business object or any of the forms if you are doing a form plugin.