Knowing when a GRN is activated  Topic is solved

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

Knowing when a GRN is activated

Postby DannyC » Mon Sep 13, 2021 10:35 am

Hi,
In the absence of a GRN Activating or Activated event, I am doing the following to fire off some code when a GRN is activated.
It works fine, but it intermittently also fires when a GRN is only opened or read. I want it to only do it's stuff when a GRN is activated only.

I am wondering if the following code is the best way to do it or if there's a better way.
Code: Select all
bool isActivating = false;

public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{

   if (JiwaForm is JiwaFinancials.Jiwa.JiwaInvReceivalUI.MainForm)
   {
      JiwaFinancials.Jiwa.JiwaInvReceivalUI.MainForm GRNForm = (JiwaFinancials.Jiwa.JiwaInvReceivalUI.MainForm)JiwaForm;
      GRNForm.InventoryReceival.ReadEnd += My_GRNReadEnd;
      GRNForm.InventoryReceival.SaveStart += My_GRNActivated;
   }
   
}

private void My_GRNActivated(object sender, System.EventArgs e)
{
   JiwaFinancials.Jiwa.JiwaInvReceival.Receival GRN = (JiwaFinancials.Jiwa.JiwaInvReceival.Receival)sender;      
   if (GRN.Status.ToString() == "Activated" && GRN.OriginalStatus.ToString() == "UnActivated")
   {
      //We're activating
      isActivating = true;
   }
   else
   {
      isActivating = false;
   }
}   


public void My_GRNReadEnd (object sender, System.EventArgs e)
{
   JiwaFinancials.Jiwa.JiwaInvReceival.Receival GRN = (JiwaFinancials.Jiwa.JiwaInvReceival.Receival)sender;
    if (isActivating)
   {
      //Do stuff
   }
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Knowing when a GRN is activated  Topic is solved

Postby Scott.Pearce » Mon Sep 13, 2021 11:02 am

You should only be handling the Save part. Here is a sample plugin:

Plugin GRN Message Upon Activation.xml
(33.95 KiB) Downloaded 269 times
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


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests