How to set focus on salesline added automatically to Quote?

havhav Member Posts: 299
edited 2012-09-19 in NAV Three Tier
Hi,

I am facing a peculiar problem after upgrading my add-on from NAV 2009 NA SP1 to NAV 2009 NA R2.

Let me first discuss my solution.

I have added a new action group to the action pane of the Sales Quote page as shown below

A similar 'Windowmaker' menu is added to the Lines fasttab of the Sales Quote page as shown below.

The only change here is that each action has a shortcut key.

The purpose of this menu is to call the add-on configurator which will allow me to design the door/window/glass item and in turn create a new sales line corresponding to the item that is created by the configurator. Note that the sales line is created automatically.

I have used SendKeys() function of Windows Script Host Object Model to invoke the action on the Lines subpage from the main Header page by passing the shortcut key shown above. See details of using SendKeys() --> http://dynamicsuser.net/blogs/mark_brum ... -pane.aspx

For each action on Sales Quote page, the OnAction() trigger is customized as shown below
NewWindow - OnAction()
//Send shortcut key 'Ctrl+A' to execute action on 'New Window' menu
WINSHELL.SendKeys('^a');
CurrPage.UPDATE(FALSE);

Similarly the OnAction() trigger on the Sales Quote Subform page is customized as shown below
<Action1100359002> - OnAction()
{CurrPage.SalesLines.FORM.}
OpenNewWMSalesLine(ItemType::Window);

The OpenNewWMSalesLine() function calls the add-on configurator which allows to design the item as required and after that it returns the item details using which it will create a new sales line corresponding to that item.

Now the problem i face.....

In SP1 when i click any of the action from the Header page, the SendKeys() function was working correctly by sending the appropriate shortcut key to the Lines page and the corresponding trigger was getting executed also.

After upgrade to R2, when i click on any of the action from the Header page, it does nothing. I later on realized that the cursor has to be on the Lines fasttab in order for the shortcut key to function. However this was not required when i use to do it in SP1.

Another thing when my configurator creates a new salesline, the Lines fasttab shows the current salesline in gray color.

Now if i click any of the action from the header page, again it does nothing.

i then manually select the above line so that the gray color vanishes and the line is seen as currently selected in blue color. Now if i click the action from the header page it works. This was not the case in SP1. For each new sales line i add via the configurator, i have to manually set the focus on any of the line on the Lines fasttab in order for the action in the header page to function correctly.

Although the OpenNewWMSalesLine() function does set the Rec var. to the newly created sales line by the configurator, i am not sure why the sales line is seen in gray color when added automatically and why there is a need for me to manually select that line in order to see it as having the current focus.

Does anyone have idea how to overcome the above?

Regards,
Hemant
Regards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)

Comments

  • havhav Member Posts: 299
    Hi,
    Any help will be much appreciated.

    Regards,
    Hemant
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • kinekine Member Posts: 12,562
    Why you are not calling the functions of the subpage directly and you are using sendkeys?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • havhav Member Posts: 299
    Hi,
    Thanks for your reply.

    As per my understanding actions in the Action Pane are executed at header level and not lines level.
    When clicking say "New Window" action in the Action Pane, even if i call the function OpenNewWMSalesLine() using CurrPage.SalesLines.FORM, the Rec variable is not initialized to the current salesline record. This is possible only if i pass the shortcut key using SendKeys() from header to line level which in turn will execute the action present on Lines fasttab.

    Let me know if you need further details.

    Regards,
    Hemant
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • skullaskulla Member Posts: 140
    I have used SendKeys function in NAV 2009 R2 but as you mentioned it will only work if you select the line, i have not tried this on NAV 2009 SP1 and i am surprised to learn that it will work even if you do not select the line.
  • havhav Member Posts: 299
    It doesn't work at my end.
    Note that i am using NAV 2009 NA-R2.

    Regards,
    Hemant
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
Sign In or Register to comment.