Hi All,
We have modified a page in BC with a new field. I have a Description3 and Description.
I would like - if Description <> '' and Description3 = '' then Description3 = Description
Currently I am doing this on a Trigger OnOpenPage - but I recognize that this is problematic if many users are accessing the same page :S. Does adding a setfilter make this better? Please see below
trigger OnOpenPage() begin rec.SetFilter("Document Type", '%1', rec."Document Type"::Order); rec.SetFilter("Document No.", rec."Document No."); repeat if (rec.multiLineDescription = '') and (rec.Description <> '') then begin rec.multiLineDescription := rec.Description; rec.modify(); end; until rec.next = 0; end;
Thank you in advance!
Thank you Zhu, I understand the use of actions now - this is definitely the way to go to perform one time processes.
I added an action on the purchaseLines page and ran it once. That performed the task in full - and then i removed the trigger OnOpenPage - which wasn't a good idea to begin with.
The reasoning for using the description3 is because my stakeholders were complaining that the original description field was single line and when users wrote something too long, it would be hard for them to read.
So I created multilinedescription - which I called description 3. It was a significant effort, but I think it is ok for now.
Thank you again
Hi, First of all, I think your development is a bit risky. It seems that you don’t use the standard Description and recreated a new Description3. When Description3 is empty, it is equal to Description, but when Description is empty and Description3 is not empty, you don’t do any process?
In the BC, such as Sales Order Line, Item Journal and other table will use Item Description. If you don’t consider it, the Description of these page may be empty.
In addition
For action:
For OnValidate (Field) Trigger
Hope this helps.
Thanks.
ZHU
Hi Zhu,
I'm not familiar with actions, and one caveat is that I want to back-fill historical data with values from Description to Description3, but moving forward Description will be invisible, and Description3 will be used instead (I have this part working).
So moving forward Description3 may <> Description. Could you link me to a good example of using actions and onValidate? Would it go on the page?
Hi, If this is a newly added field (Description3 ) and historical data already exists, it is recommended that you add a new Action to do this processing. Because it's a one-time thing.
If you are in a new environment and don't have any data yet, I suggest adding the processing to the OnValidate Trigger of the Description, and there is no need for a loop.
Hope this helps.
Thanks.
ZHU
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,151 Super User 2024 Season 2
Martin Dráb 229,993 Most Valuable Professional
nmaenpaa 101,156