mibuso.com

Microsoft Business Solutions online community
It is currently Mon May 20, 2013 11:19 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Re:
PostPosted: Thu Jun 17, 2010 6:01 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Mon Dec 11, 2006 10:34 am
Posts: 2863
Location: Bergamo
Country: Italy (it)
i know, but form variables cannot be used for my specific problem: you probably miss my previous posts, this:
Belias wrote:
[...]I do it the same way, but i've got a small (probably big) problem: i have to call some functions before running the form (page in my case, but it's not important), thus i have to declare the form as a variable in order to call the functions and run the form with the same instance...i still can't find a proper function to set a temptable variable as the form variable sourcetable:
settableview --> useless, it just sets the filters
setrecord --> useless, it just sets the "focus"
any idea?am i missing some parameter, maybe?
Thanks in advance

AND this:
Belias wrote:
F**k off!!(sorry, but i'm really disappointed)i guess i can't
viewtopic.php?f=23&t=38328

as explained in the whole topic, temptables can be passed as source only with FORM.RUN(tableno,mytemptable) syntax and not with myformvariable.run
This means that i cannot use form variables, and then i can (and do) use kriki's suggestion.
P.S.: as expected, it works like a charm :thumbsup:, i could finally remove those system fields i put in the table just to have their value...
i created a monster form, i'll post some code snippets about it when i'll have some times...
it's a form + subform with both header and lines as temporary tables populated from a report. There are also some variables "as fields" in the subform. :mrgreen:

_________________
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog


Top
 Profile  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Fri Jun 18, 2010 1:18 pm 
Offline

Joined: Fri Jul 24, 2009 11:55 am
Posts: 28
Location: Bergamo
Country: Italy (it)
I use a different technique to solve Belias problem.

Add a function to form (page) (the form (page) that use temporary table) like this:

GetTempTable(VAR : Record TableName)
TableName.COPY(Rec.TRUE);

Tablename is the same of Rec of the Form/Page.
Function parameter is passed by VAR and the record is of the same type of form (page) Rec.
Notice parameters is NOT defined as temporary. Notice also i use paremater TRUE in COPY function (this is a very useful option in COPY functions!)

I define a form (page) variable in a codeunit or in another form (page)
Name DataType Subtype Length
FormwithTemporaryrec Form Item Journal

From the form/page/codeunit a call the function
FormwithTemporaryrec.GetTempTable(X)

X ia a variable of type rec, subtype the sabe of Rec of FormwithTemporaryrec
X is defined as Temporary

After this call you cal use X variable (you can insert records).
If you open the form with
FormwithTemporaryrec.RUNMODAL,
the form will show the record you inserted in calling form/page/codeunit.


Top
 Profile E-mail WWW  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Fri Jun 18, 2010 3:06 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Mon Dec 11, 2006 10:34 am
Posts: 2863
Location: Bergamo
Country: Italy (it)
Great! this is even better than the singleinstance codeunit! =D>
I've always underestimated the COPY function...thanks a lot!

_________________
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog


Top
 Profile  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Fri Jun 18, 2010 4:16 pm 
Offline

Joined: Mon May 18, 2009 6:36 am
Posts: 792
Location: India
Country: India (in)
Belias wrote:
Great! this is even better than the singleinstance codeunit! =D>
I've always underestimated the COPY function...thanks a lot!


with respect,
As my above post when i am sending parameter to form by function then why can't we send Rec type parameter even if we have to set it Call by Var.

_________________
Vijay Gupta
Changing the code is last step. Try to change processes first...


Top
 Profile E-mail  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Fri Jun 18, 2010 4:29 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Mon Dec 11, 2006 10:34 am
Posts: 2863
Location: Bergamo
Country: Italy (it)
vijay_g wrote:
Belias wrote:
Great! this is even better than the singleinstance codeunit! =D>
I've always underestimated the COPY function...thanks a lot!


with respect,
As my above post when i am sending parameter to form by function then why can't we send Rec type parameter even if we have to set it Call by Var.

Can you write the exact code you would have written, please? probably it's just mine misunderstanding of your post :-k

_________________
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog


Top
 Profile  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Fri Jun 18, 2010 4:39 pm 
Offline

Joined: Mon May 18, 2009 6:36 am
Posts: 792
Location: India
Country: India (in)
before....
FormwithTemporaryrec.GetTempTable(Par1,par2)
now instead of this....

Code: Select all
FormwithTemporaryrec.GetTempTable(Rec);

where Rec is call by var in function

_________________
Vijay Gupta
Changing the code is last step. Try to change processes first...


Top
 Profile E-mail  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Fri Jun 18, 2010 5:19 pm 
Online
Moderator
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Wed Jul 02, 2003 10:13 am
Posts: 7493
Location: Milan
Country: Italy (it)
stevedivimast wrote:
I
TableName.COPY(Rec.TRUE);

Tablename is the same of Rec of the Form/Page.
Function parameter is passed by VAR and the record is of the same type of form (page) Rec.
Notice parameters is NOT defined as temporary. Notice also i use paremater TRUE in COPY function (this is a very useful option in COPY functions!)


WOW! I just learned something new! I never noticed the second parameter in the copy-functions!

I just checked a moment and the second parameter exists only form NAV2009! It doesn't exist in 5.0SP1!

_________________
Regards,Alain Krikilion
Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title! || Read Forum Rules before making a posting


Top
 Profile  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Fri Jun 18, 2010 5:37 pm 
Offline

Joined: Mon May 18, 2009 6:36 am
Posts: 792
Location: India
Country: India (in)
stevedivimast wrote:
Notice parameters is NOT defined as temporary. Notice also i use paremater TRUE in COPY function (this is a very useful option in COPY functions!)


comment....
If ShareTable is true, both Record and FromRecord must be temporary; otherwise an error will occur.

_________________
Vijay Gupta
Changing the code is last step. Try to change processes first...


Top
 Profile E-mail  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Wed Jun 23, 2010 12:56 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Mon Dec 11, 2006 10:34 am
Posts: 2863
Location: Bergamo
Country: Italy (it)
Here you are a sample on how to use the sharetable parameter as suggested by stevedivimast =D>
(copy and paste the code in a text object: pages 50003 & 50004)
Code: Select all
OBJECT Page 50003 factboxtest
{
  OBJECT-PROPERTIES
  {
    Date=23/06/10;
    Time=12.50.23;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    SourceTable=Table27;
    PageType=List;
    SourceTableTemporary=Yes;
  }
  CONTROLS
  {
    { 1101366000;0;Container;
                ContainerType=ContentArea }

    { 1101366001;1;Group  ;
                Name=Group;
                GroupType=Repeater }

    { 1101366002;2;Field  ;
                SourceExpr="No." }

    { 1101366003;2;Field  ;
                SourceExpr=Description }

  }
  CODE
  {

    PROCEDURE FNTPopTable@1101366000(VAR Tbsource@1101366000 : Record 27);
    BEGIN
      Tbsource.COPY(Rec,TRUE);
    END;

    BEGIN
    END.
  }
}

OBJECT Page 50004 cardpagetest
{
  OBJECT-PROPERTIES
  {
    Date=23/06/10;
    Time=12.50.56;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    SourceTable=Table27;
    PageType=Card;
    OnOpenPage=BEGIN
                 CurrPage.factboxtest.FORM.FNTPopTable(TBTempitem);
                 TBTempitem."No." := 'mirkomirkom';
                 TBTempitem.INSERT;
               END;

    OnAfterGetRecord=BEGIN
                       TBTempitem."No." += 'm';
                       TBTempitem.INSERT;
                     END;

  }
  CONTROLS
  {
    { 1101366000;0;Container;
                ContainerType=ContentArea }

    { 1101366001;1;Group  ;
                Name=General;
                GroupType=Group }

    { 1101366002;2;Field  ;
                SourceExpr="No." }

    { 1101366003;2;Field  ;
                SourceExpr="No. 2" }

    { 1101366004;2;Field  ;
                SourceExpr=Description }

    { 1101366005;2;Field  ;
                SourceExpr="Search Description" }

    { 1101366006;0;Container;
                ContainerType=FactBoxArea }

    { 1101366007;1;Part   ;
                Name=factboxtest;
                PagePartID=Page50003 }

  }
  CODE
  {
    VAR
      TBTempitem@1101366000 : TEMPORARY Record 27;

    BEGIN
    END.
  }
}


this example is really stupid, but interesting because it shows how powerful is this function if you want to determine the behaviour of factboxes, too.

Remark: i noticed a small drawback of the sharetable method VS the singleinstance method: if you have a page that has NOT the sourcetabletemporary property set to yes, in order to use the sharetable method you have to replicate the same page, and set the sourcetabletemporary to yes. Otherwise the copy function will return an error, as expected.

_________________
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog


Top
 Profile  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Thu Jun 24, 2010 7:48 pm 
Offline

Joined: Fri Jul 24, 2009 11:55 am
Posts: 28
Location: Bergamo
Country: Italy (it)
t's also possible in a Page with a temporary Rec to change "dinamically" the Rec Itself.

To do this add a function to this page like this:

ChangeTmpRec(VAR TableName : TEMPORARY Record Item)
Rec.COPY(TableName,TRUE);
EXIT;

Please, notice the sharetable parameter in COPY function.
Then if you use a Page Variable (in a page or in a codeunit) you can do this:

PageVar.ChangeTmpRec(TempItemVar)
PageVar.RUN (or RUNMODAL)

(TempItemVar is defined as Record Item Temporary)

The page will use TempItemVar instead of original Page Rec.
Tested in Nav2009 and NAv2009Sp1)

This technique is similar to that one on my previous post.
In this case i "tell" to tha page the temporary record to use, in the previuos one I "ask" to the page the teporary recor it uses.

If you try to use this technique with a form you get a very strange behavior:
The first time you open the form it work fine. The second one will crash Navision (you have to restart).
I sended this error to Miscosoft people.


Top
 Profile E-mail WWW  
 
 Post subject: Re:
PostPosted: Mon Jun 20, 2011 7:58 am 
Offline

Joined: Thu May 01, 2008 1:57 pm
Posts: 368
Location: Ahmedabad, India
Country: India (in)
Slawek Guzek wrote:
You can run similar funcionality in 4.x but you have to:

1. Create variable based on record of your interest
2. Set the TEMPORARY property of variable to YES
3. Fill temporary variable with data
4. Run the form using syntax:

Code: Select all
FORM.RUN(FORM::"YourFormHere",YourTempRecVariable);


Regards,
Slawek

To have the same functionality for RTC PAge, then what can be done?
For your information, replacing just FORM to PAGE is not working in above code.

Please, suggest.

_________________
Ravi_Thakkar
Ahmedabad, Gujarat, India
E Mail : ravi.thakkar@hotmail.com


Top
 Profile E-mail  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Tue Jan 03, 2012 7:28 am 
Offline

Joined: Mon Aug 31, 2009 12:07 am
Posts: 5
I am trying to do this with a ListPart Page in NAV 2009 R2 but nothing seems to work. I want a FactBox with a calulated number of lines based on the line that is being filtered. Think about this example as if I was pulling the top 5 customers around the customer that is chosen.


Top
 Profile E-mail  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Fri Aug 31, 2012 3:14 pm 
Offline

Joined: Fri Aug 28, 2009 11:46 am
Posts: 27
Country: United Kingdom (uk)
tburger wrote:
I am trying to do this with a ListPart Page in NAV 2009 R2 but nothing seems to work. I want a FactBox with a calulated number of lines based on the line that is being filtered. Think about this example as if I was pulling the top 5 customers around the customer that is chosen.


An old post... but did you have any sucess with this? We want to do a similar thing too.

cheers, Tim


Top
 Profile E-mail  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Tue Sep 04, 2012 9:01 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Mon Dec 11, 2006 10:34 am
Posts: 2863
Location: Bergamo
Country: Italy (it)
some builds in the NAV R2 fires the onaftergetrecord trigger unexpectedly.
e.g.: you open the page and the client fires the onaftergetrecord trigger like an heavy machine gun (ref. metal slug :mrgreen: ), then the trigger is not fired anymore when you browse through records.
Try with the last build.

_________________
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog


Top
 Profile  
 
 Post subject: Re: Use the SourceTableTemporary property.
PostPosted: Thu Sep 13, 2012 12:55 pm 
Offline

Joined: Fri Aug 28, 2009 11:46 am
Posts: 27
Country: United Kingdom (uk)
Belias wrote:
some builds in the NAV R2 fires the onaftergetrecord trigger unexpectedly.
e.g.: you open the page and the client fires the onaftergetrecord trigger like an heavy machine gun (ref. metal slug :mrgreen: ), then the trigger is not fired anymore when you browse through records.
Try with the last build.


Thanks for the heads up on that one. I've seen it doing strange things already. I don't think it will solve my requirement of having a factbox update against a list part line though as we can't know what the current record is. We could do with the "OnAfterGetCurrRecord" trigger back. [-o<


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: