Handle click of new Button on listPages

PizzamakaPizzamaka Member Posts: 11
edited 2010-07-22 in NAV Three Tier
Hi.

I am trying to migrate a classic app to the RTC. I have a List-Form which opens a Card-Form when "New Record" is clicked and preinitializes the Card-Form with some Data. My Problem now is, that I can't seem to handle the click on the default "new" Button which is displayed on List-Forms in order to write my Data to the Card. Does anybody have an idea?

thanks in advance.

Comments

  • David_SingletonDavid_Singleton Member Posts: 5,479
    Remember when you were told "don't write any code on forms that modifies data" well now you see why.

    :whistle:
    David Singleton
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Try to look at a different way of achieving what you are doing. I am sure eventually you can make it work the direction you are heading, but better is to work out a way that does not require code at the form/page level.
    David Singleton
  • PizzamakaPizzamaka Member Posts: 11
    I have tried to think about abother solution, but couldn't come up with one.

    The problem is, that the list form is used in two different ways:
    1. just to see all entries
    2. filtered to see all items related.

    When it is open in the second way and I want to add a new item it must set some fields in order to create the relation. If you have any idea on how to achieve such a thing without any code in the form I would appreciate it.

    The only way I could think of is to create a page/form where I manually create buttons + code to view/create a row. I don't like this solution though and I beleive, that there must be a way that is nicer.

    I also thought to use the table, but I don't have the record that is passed to the card when new is clicked, so that I cannot preset any fields there.
  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    I think the solution you are looking for is that the filters in your second case needs to be in filtergroup 2 - then they will be honored by the automatic New action.
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • PizzamakaPizzamaka Member Posts: 11
    Hi freddy,

    I have tried putting the filter in filtergroup 2 and verified it through a message in the card page. Sadly I have no luck.

    I have put a message in the onopenpage-trigger to print the filter and the group and I noticed a strange behaviour: When the page is opened at first the desired filters are set in group 2. Right after the first messagebox pops up a sencond messagebox pops up showing an empty filter.

    It seems, that the page is opened with the correct filters, after which the filters are deleted and the triggers are executed again.

    [edit]
    I also think, that filling fields by filters is only possible, when the fields to be filled are in the primary key, right?
    [/edit]
  • mihail_kolevmihail_kolev Member Posts: 379
    try this:
    Add action in the list page.
    RunFormMode - Create
    Image - NewDocument
    Promoted - Yes
    PromotedCategory - New
    PromotedIsBig - Yes
    RunFormView - Filter the fields you want to set (ex.: WHERE(Template=Yes) )

    In the card page in the OnNewRecord Trigger call
    xRec.FILTERGROUP(3);
    tmpStr:=xRec.GETFILTERS;

    In my case the tmpStr='Template=Yes'
    btw. it depends on language. In german tmpStr='Template=Ja'

    now you can parse the tmpStr and set the fields of your choice.

    This is not handling of the standart New action but is some solution.
    -Mihail- [MCTS]
  • dhitzemanndhitzemann Member Posts: 6
    I am having an issue with this as well with the RTC.
    I have created two new pages, a list page and a card. When looking at the list and the user wants to create a new record, they select the new button in the RTC. When the card is opened for the new record, I have several fields I want to default from the previous record. How do I get this to work in the RTC?

    I actually got this working on the list form (not quite sure how it did it) and I can create a new record directly on the list form, but when I open the card with the New button, I cannot get any defaults to populate.

    A little help please?
  • OttoOtto Member Posts: 17
    freddy.dk wrote:
    I think the solution you are looking for is that the filters in your second case needs to be in filtergroup 2 - then they will be honored by the automatic New action.

    I try to default the value for some field based on the filter apply on the List Page. However i found that the automatic New Action only honored the filter if I run the filter the List Page using RunFormLink Property. I try to use Filter Group 2 on Open Page Trigger but it seems this filter is ignored by the Automatic New Action.
Sign In or Register to comment.