I created a new field in a Page (P95). The source expression is the field Comment of T44.
When I validate that field how can I get its value if it's not referred to a record?
I want to access to its temporary value. This textbox compares on the page like a field, but if you type a value on it and then you close and open the page the value is erased.
I can't find out how to get this value, and memorize it in a table. I think I can do it in the OnValidate trigger.
But it's not a record. I wnat to access it to memorize it on a table.
if you used variable in textbox and want value of this in related table then make a function in table and pass a parameter and call this from Onaftergetrecord trigger.
I don't close the page. I keep it open, and I want that when I type something in the textbox the variable assumes that text. Is there a specific event? It should be OnValidate but it doesn't work
Can you be more clear what exactly you need with example and WHY?
A customer wants an additional field in P95 (Sales Quote Subform). We don't want to add fields in the table, so we thought: "Let's add a field (Date Supporto) only in the page, with SourceExpr property assigned to a variable (DateSupporto). Each time the customer writes something in this field that value is stored in the Sales Comment Line (T44). So we don't create new columns."
Here is the code. The record variable Commenti2 refers to the Sales Comment Line, and this is the code I wrote in the trigger OnValidate of field Date Supporto in Page 95.
IF Commenti2.GET("Document Type","Document No.","Line No.",10000) THEN BEGIN
Commenti2.Comment:= DateSupporto;
Commenti2.MODIFY;
END ELSE BEGIN
Commenti2.INIT;
Commenti2."Document Type":= "Document Type";
Commenti2."No.":= "Document No.";
Commenti2."Document Line No.":= "Line No.";
Commenti2."Line No." := 10000;
Commenti2.Comment:=DateSupporto;
Commenti2.INSERT
END;
I may not have understood the problem well, but coming to your original issue, like "not able to read the value of the variable DateSupportTo from the Page". I did something similar on page 95,
1. Declared a variable DateSupportTo as Date
2. Added it to the last field in the subform page
3. Created a Local function (DateSupportTo - in the properties select Local as Yes) and
4. added the following code to the function:
IF DateSupportTo = TODAY() THEN
MESSAGE('Date entered is Today!');
It works for me. I am not sure what you want to do with the storing part of the situation, but I guess if you can get the value you can always store it wherever you want to..
It's not exactly what I wanted but it's interesting, thank you very much :-)
There is another problem now ](*,) ...
Whene I create a new line in P95 (Sales wuote subform) and I compile the value of the field Date Supporto, the entry that I create in the Sales Comment Line with the code I wrote some posts ago (and that I copy here) is created with Document Line No. = 0, and not equal to the value of the line document.
IF Commenti2.GET("Document Type","Document No.","Line No.",10000) THEN BEGIN
Commenti2.Comment:= DateSupporto;
Commenti2.MODIFY;
END ELSE BEGIN
Commenti2.INIT;
Commenti2."Document Type":= "Document Type";
Commenti2."No.":= "Document No.";
Commenti2."Document Line No.":= "Line No.";
Commenti2."Line No." := 10000;
Commenti2.Comment:=DateSupporto;
Commenti2.INSERT
END;
Is it that when you create a new line in any document the Document Line is equal to zero? Damn!
It means that the line no. is not yet assigned when you added the value in DateSupporto field..
first insert all details and move cursor to next line or previos line and then insert the DateSupporto value..and check
Yes you are right... but it is so uncomfortable! It overwrite the comment of header :-(...
I modified the code to avoid this:
IF Commenti2.GET("Document Type","Document No.","Line No.",10000) THEN BEGIN
IF "Line No." <> 0 THEN BEGIN
Commenti2.Comment:= DateSupporto;
Commenti2.MODIFY;
END ELSE
DateSupporto := ''
END ELSE BEGIN
Commenti2.INIT;
Commenti2."Document Type":= "Document Type";
Commenti2."No.":= "Document No.";
Commenti2."Document Line No.":= "Line No.";
Commenti2."Line No." := 10000;
Commenti2.Comment:= DateSupporto;
Commenti2.INSERT
END;
But it remains uncomfortable.... any better ideas? :-k
It's not exactly what I wanted but it's interesting, thank you very much :-)
There is another problem now ](*,) ...
Whene I create a new line in P95 (Sales wuote subform) and I compile the value of the field Date Supporto, the entry that I create in the Sales Comment Line with the code I wrote some posts ago (and that I copy here) is created with Document Line No. = 0, and not equal to the value of the line document.
IF Commenti2.GET("Document Type","Document No.","Line No.",10000) THEN BEGIN
Commenti2.Comment:= DateSupporto;
Commenti2.MODIFY;
END ELSE BEGIN
Commenti2.INIT;
Commenti2."Document Type":= "Document Type";
Commenti2."No.":= "Document No.";
Commenti2."Document Line No.":= "Line No.";
Commenti2."Line No." := 10000;
Commenti2.Comment:=DateSupporto;
Commenti2.INSERT
END;
Is it that when you create a new line in any document the Document Line is equal to zero? Damn!
It should work with a Currpage.SAVERECORD just before your code
Your requirement is similar to Shortcut Dimension functionality in gen. journal lines. You can have a look at this.
A few times I implemented similar solutions and basically you have to do the following:
Create a temporary record after the validation of your variable (if line hasn't been inserted)
Copy temporary record to normal record after the line's insertion.
Your requirement is similar to Shortcut Dimension functionality in gen. journal lines. You can have a look at this.
A few times I implemented similar solutions and basically you have to do the following:
Create a temporary record after the validation of your variable (if line hasn't been inserted)
Copy temporary record to normal record after the line's insertion.
Where is created the temporary record? In a record variable?
And how can I find the correct "Document Line No."?
Create 3 functions in the page. Call InsertComment function OnInsertRecord and OnValidate of DateSupporto field.
1)InsertComment
IF "Line No." = 0 THEN
SaveToTempComment
ELSE
CopyFromTempComment;
2) SaveToTempComment
IF TempSalesCommentLine.GET("Document Type","Document No.","Line No.",10000) THEN BEGIN
TempSalesCommentLine.Comment:= DateSupporto;
TempSalesCommentLine.MODIFY;
END ELSE BEGIN
TempSalesCommentLine.INIT;
TempSalesCommentLine."Document Type":= "Document Type";
TempSalesCommentLine."No.":= "Document No.";
TempSalesCommentLine."Document Line No.":= "Line No.";
TempSalesCommentLine."Line No." := 10000;
TempSalesCommentLine.Comment:=DateSupporto;
TempSalesCommentLine.INSERT
END;
3) CopyFromTempComment
IF TempSalesCommentLine.GET("Document Type","Document No.",0,10000) THEN BEGIN
SalesCommentLine := TempSalesCommentLine;
SalesCommentLine."Document Line No." := "Line No.";
SalesCommentLine.INSERT;
TempSalesCommentLine.DELETE;
END;
This code is only for give an idea on how to insert. You have to check it and modify upon your case. Also, you may require writing additional code to display your variable properly.
Create 3 functions in the page. Call InsertComment function OnInsertRecord and OnValidate of DateSupporto field.
1)InsertComment
IF "Line No." = 0 THEN
SaveToTempComment
ELSE
CopyFromTempComment;
2) SaveToTempComment
IF TempSalesCommentLine.GET("Document Type","Document No.","Line No.",10000) THEN BEGIN
TempSalesCommentLine.Comment:= DateSupporto;
TempSalesCommentLine.MODIFY;
END ELSE BEGIN
TempSalesCommentLine.INIT;
TempSalesCommentLine."Document Type":= "Document Type";
TempSalesCommentLine."No.":= "Document No.";
TempSalesCommentLine."Document Line No.":= "Line No.";
TempSalesCommentLine."Line No." := 10000;
TempSalesCommentLine.Comment:=DateSupporto;
TempSalesCommentLine.INSERT
END;
3) CopyFromTempComment
IF TempSalesCommentLine.GET("Document Type","Document No.",0,10000) THEN BEGIN
SalesCommentLine := TempSalesCommentLine;
SalesCommentLine."Document Line No." := "Line No.";
SalesCommentLine.INSERT;
TempSalesCommentLine.DELETE;
END;
This code is only for give an idea on how to insert. You have to check it and modify upon your case. Also, you may require writing additional code to display your variable properly.
It's clever! But...
...in the end my boss decided to create new fields in table in the end :-)
Thank you very much, everybody
Answers
What does this mean could you be more clear on it.
I want to access to its temporary value. This textbox compares on the page like a field, but if you type a value on it and then you close and open the page the value is erased.
I can't find out how to get this value, and memorize it in a table. I think I can do it in the OnValidate trigger.
if you type a value on it and want to save this in table field that you have to add then write code on onvalidate of this textbox.
I know that. I need to know how to refer in the code to the text box. If it was a record I would use Rec.NameField.
But it's not a record. I wnat to access it to memorize it on a table.
And if I use CurrPage.NameField it doesn't work, because I need the temporary value, not the control.
if you used variable in textbox and want value of this in related table then make a function in table and pass a parameter and call this from Onaftergetrecord trigger.
But this variable doesn't change value when I validate the textbox. This is the real problem, maybe I finally explain it correctly, sorry :-k
if you are calculating value to show in this control for each line then how can it show you the value(after reopen this page) that you type on this.
Hope now it's clear to you.
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
A customer wants an additional field in P95 (Sales Quote Subform). We don't want to add fields in the table, so we thought: "Let's add a field (Date Supporto) only in the page, with SourceExpr property assigned to a variable (DateSupporto). Each time the customer writes something in this field that value is stored in the Sales Comment Line (T44). So we don't create new columns."
Here is the code. The record variable Commenti2 refers to the Sales Comment Line, and this is the code I wrote in the trigger OnValidate of field Date Supporto in Page 95.
IF Commenti2.GET("Document Type","Document No.","Line No.",10000) THEN BEGIN
Commenti2.Comment:= DateSupporto;
Commenti2.MODIFY;
END ELSE BEGIN
Commenti2.INIT;
Commenti2."Document Type":= "Document Type";
Commenti2."No.":= "Document No.";
Commenti2."Document Line No.":= "Line No.";
Commenti2."Line No." := 10000;
Commenti2.Comment:=DateSupporto;
Commenti2.INSERT
END;
without opening comments page,you want to insert/updated comments...
What problem are you facing in this?
I tried your code on Form and its working fine..please Insert Workdate as Date while inserting ..
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
Ok, now it works ... i made confusion with different Designers open of the same Page... I'm sorry, I'm a noob at this, thank you all for your help!
One last thing: Why do I have to insert Work Date? Is it important?
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
1. Declared a variable DateSupportTo as Date
2. Added it to the last field in the subform page
3. Created a Local function (DateSupportTo - in the properties select Local as Yes) and
4. added the following code to the function:
IF DateSupportTo = TODAY() THEN
MESSAGE('Date entered is Today!');
It works for me. I am not sure what you want to do with the storing part of the situation, but I guess if you can get the value you can always store it wherever you want to..
Was this what you wanted?
There is another problem now ](*,) ...
Whene I create a new line in P95 (Sales wuote subform) and I compile the value of the field Date Supporto, the entry that I create in the Sales Comment Line with the code I wrote some posts ago (and that I copy here) is created with Document Line No. = 0, and not equal to the value of the line document.
Is it that when you create a new line in any document the Document Line is equal to zero? Damn!
first insert all details and move cursor to next line or previos line and then insert the DateSupporto value..and check
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
Yes you are right... but it is so uncomfortable! It overwrite the comment of header :-(...
I modified the code to avoid this:
But it remains uncomfortable.... any better ideas? :-k
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
LOl
In fact there is a bug.. if you :
-select one line (for example the first line)
-click Line-->Comment
-select another line (for example second line)
-click Line-->Comment
It opens the comment for the first line!!!! You have to click Comment again to get the right ones!
If you are using standard navision..
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
I added it, but the "Line No." is always zero ...
A few times I implemented similar solutions and basically you have to do the following:
Create a temporary record after the validation of your variable (if line hasn't been inserted)
Copy temporary record to normal record after the line's insertion.
Pargesoft
Where is created the temporary record? In a record variable?
And how can I find the correct "Document Line No."?
1)InsertComment
2) SaveToTempComment
3) CopyFromTempComment
This code is only for give an idea on how to insert. You have to check it and modify upon your case. Also, you may require writing additional code to display your variable properly.
Pargesoft
It's clever! But...
...in the end my boss decided to create new fields in table in the end :-)
Thank you very much, everybody