Switching between two data sources at runtime in a form

rashi.kaushikrashi.kaushik Member Posts: 52
edited 2006-03-23 in Dynamics AX
Hi All

I am Customizing the SalesOrder form.
I have added a view also to the existing data sources of the form.
Now the requirement is that there will be a check box on the form itself and as soon as the user checks the check box the forms data source should switch to view and vice versa.

Thanks in advance

Rashi

Comments

  • MugurMugur Member Posts: 93
    Hi

    Simply said, you should duplicate the existing form controls and link the duplication controls to fields in the View (while the origial controls remain linked to the table). Then switch controls visibility when the checkbox is changed and make sometime visible only those having ds=salestable, then hide those and only show the others (with the View).

    However this way you are complicating very much the screen. Why not creating a brand new form identical with the first (by duplicating it) and with the View as datasource. Place a button on each form to open the other with the correct parameters, so the user will always get access to both forms.

    HTH...
    Kind regards,

    Ciprian Dudau
    Axapta Developer
  • rashi.kaushikrashi.kaushik Member Posts: 52
    Thanks Mugur

    Now the form's design changes as i try to click the checkbox.
    But my problem now is:

    I have 2 Views
    SalesTableView and SalesLineView
    When i click the checkbox the form comes in view mode but now since there is no realtion between these views the SalesLineView does not display the related records instead it display all the records.
    I have set the JoinSource property of SalesLineView in data source as SalesTableView.

    Thanks in advance
    Rashi
  • MugurMugur Member Posts: 93
    Yes, I tested and the same happened to me ](*,) . We need to do some tricks for this.

    Add in classdeclaration() of the form the following:
    QueryBuildRange   rangeSalesId;
    

    Then in datasource SalesViewLines.init() (after super() call)
    rangeSalesId = this.query().datasourceno(1).addrange(fieldnum(SalesViewLines,SalesId));
    

    Then in datasource SalesViewTable.active() (also after super() call)
    rangeSalesId.value(salesViewTable.salesId);
    SalesViewLines_ds.executequery();
    

    This should work.
    Kind regards,

    Ciprian Dudau
    Axapta Developer
  • rashi.kaushikrashi.kaushik Member Posts: 52
    Thanks Mugur.

    Its working absolutely fine now.
    Thanks a lot once again.
    Rashi
  • rashi.kaushikrashi.kaushik Member Posts: 52
    Hi Mugur,

    Can u pls help me with this also.

    Now the same problem is with the MarkUpTrans table also.
    When i Salestable form is in View mode i.e. the datasources are SalesTableView and SalesLineView and i open MarkUpTrans from SalesTableView the MarkUpTrans is also opened in view mode i.e. the DS is MarkUpTransView but its not showing the related records. The DS of the menu Item Button of MarkUptrans is SalesTableView.

    Thanx in advance
    Rashi
Sign In or Register to comment.