The SourceTableTemporary is a new property introduced in 5.0 giving all kinds of new capabilities of showing data that is not even in the database.
Instead of showing real data from the database, the form is running on an empty table when starting up, so you will have to populate it with data.
Step 1.
Create a normal form with the wizard and define your sourcetable. Select the columns you want to (ab)use.
Make sure to select the SourceTableTemporary property.
In our example we will use table 18, Customer and select columns No. and Name.
Step 2.
Create a new function "InitTempTable"
In this function define a Local variable "Cust", type Record, Subtype 18. (Customer).
Write the following piece of C/AL Code
Cust.SETFILTER(Balance, '>1000');
Cust.SETFILTER("Country/Region Code" , 'NL');
If Cust.FINDSET THEN REPEAT
Rec := Cust;
INSERT;
UNTIL Cust.NEXT = 0;
Cust.SETFILTER(Balance, '>500');
Cust.SETFILTER("Country/Region Code" , '<>NL');
If Cust.FINDSET THEN REPEAT
Rec := Cust;
INSERT;
UNTIL Cust.NEXT = 0;
Step 3
Go to the OnOpenForm trigger and put the new function in there.
Result
A view of your customers with a filter that is normaly not possible with the normal filters still available.
The idea and example are from form 634 Chart of Accounts Overview in 5.0. You'll also find a great example there of how to expand and collapse.
For a customer I've built a view combining 2 tables based on a date filter with quantities summed up from other tables. It is very easy to use and setup and when using proper indexing the performance is perfect.
Good luck.
Comments
This is Kiran. I have verified in my database with hotfix nav5.00 the form property you specified 'sourcetabletemporary' . But, I did't get that in my database version 4.00 SP3.
Let please know to me about the Property with any .fob file.
Kiran.
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:
Regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
MCP+I, MCSE NT, Navision MCT (2004,2005)
Of course if you don't want to hardcode the filters you'll need to DELETEALL and re-populate the temp table. But the problem is that some genius might change SourceTableTemporary to NO and boom, your table is nuked, hope you have a backup from yesterday. So IMHO you should never DELETALL a temporary table. In the usual cases you can solve it by making it local to a function but not in this case. So what to do? My solution is to use a processing-only report where the user can set the filters the usual way, then the report will populate the temp table and run the form on it. No further processing on the form therefore no need to DELETEALL.
So I was using this property for the first time today and found out a bit of an issue with deleting.
When you delete a temporary record it runs all the code on the delete trigger of the record. So in my case the form was bases on the item table, when I deleted the temporary record it didn't delete the actual item record but it did delete any related data. So in my test case it deleted all the comments associated with the item.
To stop this I put the following code on the form:
Form - OnDeleteRecord() : Boolean
DELETE(FALSE);
EXIT(FALSE);
I think that's ok, if someone has a better solution please let me know :-)
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
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
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
http://www.mibuso.com/forum/viewtopic.php?f=23&t=38328
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
-create a singleinstance codeunit with 2 functions: "SaveInfo" and "GetInfo".
Before running FORM.RUNMODAL, run the function "SaveInfo" in which you pass your parameter you want to give to the form
In the OnOpenForm of your form, run function GetInfo that returns the parameter you just saved in the SingleInstance codeunit.
I use this technique VERY often.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
You're OUTSTANDING!
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
He He just a busy day for spammers today.
if you want to send parameter to a form just take a variable type FORM and create a function in form to be run, before running form call this function and you can send parameter to form.
in this case form also holds values given by report.
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.
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
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.
I've always underestimated the COPY function...thanks a lot!
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
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.
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
FormwithTemporaryrec.GetTempTable(Par1,par2)
now instead of this....
where Rec is call by var in function
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!
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
comment....
If ShareTable is true, both Record and FromRecord must be temporary; otherwise an error will occur.
(copy and paste the code in a text object: pages 50003 & 50004) 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.
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
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.
For your information, replacing just FORM to PAGE is not working in above code.
Please, suggest.
Ahmedabad, Gujarat, India
E Mail : ravi.thakkar@hotmail.com
An old post... but did you have any sucess with this? We want to do a similar thing too.
cheers, Tim
e.g.: you open the page and the client fires the onaftergetrecord trigger like an heavy machine gun (ref. metal slug ), then the trigger is not fired anymore when you browse through records.
Try with the last build.
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
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<
I had this same issue, and managed to solve it by making the list page a PageType Worksheet, and using the OnAfterGetRecord trigger to call a function in the factbox, to which I was passing information. The factBox was a cardpart.
I tried a lot of updating functions, and none of them seemed to work but I stumbled upon that as a solution.
This was on 2009 build 32012.