I am having a custom action on 2 different pages. 'event card' and 'event template', and on both actions the same page are getting opened (Eventcat.print) and on the template page, the template no and type will come automatically. if I add the same template no in the event card. I am trying to copy all the records ie the 'type' and the 'template no.' into the event card., and now the template number and type are coming, but I have a 3-column code. in 'Event cat.print' Page. which is a lookup to another table(category print) and the user manually selects the code, but now I need to copy the 'code' to the event card .based on the event template number.
action("Event Cat. Print") { Caption = 'Event Cat. Print'; ApplicationArea = all; Image = Accounts; trigger OnAction() var Eventcategoryprint3: Record "Event Cat. Print" temporary; Categoryprint: Record "Category Print"; begin Eventcategoryprint3.Reset(); Eventcategoryprint3.SetRange(No, REC."No."); if not Eventcategoryprint3.FindFirst() then begin Message('no'); Eventcategoryprint3.Init(); Eventcategoryprint3.Type := Eventcategoryprint3.Type::"Event"; Eventcategoryprint3.No := rec."No."; Eventcategoryprint3.code := Eventcategoryprint3.code; Eventcategoryprint3.Insert(); end; if rec."Template No." <> '' then begin Message('yes'); Eventcategoryprint3.Reset(); Eventcategoryprint3.SetRange(No, Rec."Template No."); if not Eventcategoryprint3.FindFirst() then begin Categoryprint.Reset(); Categoryprint.SetRange(code, Eventcategoryprint3.No); IF not Categoryprint.FindFirst() THEN begin Message('categoryprint%1', Categoryprint.code); Eventcategoryprint3.Init(); Eventcategoryprint3.Type := Eventcategoryprint3.Type::Template; Eventcategoryprint3.No := rec."Template No."; Eventcategoryprint3.code := Categoryprint.code; Eventcategoryprint3.Insert(); end; end; end; Eventcategoryprint3.Reset(); page.Run(50001, Eventcategoryprint3);// end;
I am looking for a result like these but in my case 'code' [ A, B is blank
yes, that is what happening now ....
in both the pages same table used that is what the issue otherwise it will be easy to assign the value. On the same action i can make the modification or on the page level on afterget record will be more efficient?
thanks for your help ,let me try to modify the code, Thanks you.
Yes it will never work, because there is nothing with Categoryprint.findfirst, so it will not assign any value. You need to either generate a new code. or modify your code.
Thanks.
here the code will be the Eventcategoryprint3.code := Categoryprint.code; ,this is the possible one but no luck it doesnot the works,
the code is coming from different table --> categoryprint.
thats why iam trying to setrange with the template no and code , but still its doesnot work
Then How you want to generate the Code here?
Thanks.
Thanks for the reply Nitin Verma here the isssue is there is no record in the event header with code, so we cannot use like you suggested---> Eventcategoryprint3.code := Rec.code; //See this if this ok or Generate new one
Please check the yellow one in your code.
action("Event Cat. Print")
{
Caption = 'Event Cat. Print';
ApplicationArea = all;
Image = Accounts;
trigger OnAction()
var
Eventcategoryprint3: Record "Event Cat. Print" temporary;
Categoryprint: Record "Category Print";
begin
Eventcategoryprint3.Reset();
Eventcategoryprint3.SetRange(No, REC."No.");
if not Eventcategoryprint3.FindFirst() then begin
Message('no');
Eventcategoryprint3.Init();
Eventcategoryprint3.Type := Eventcategoryprint3.Type::"Event";
Eventcategoryprint3.No := rec."No.";
Eventcategoryprint3.code := Rec.code; //See this if this ok or Generate new one
Eventcategoryprint3.Insert();
end;
if rec."Template No." <> '' then begin
Message('yes');
Eventcategoryprint3.Reset();
Eventcategoryprint3.SetRange(No, Rec."Template No.");
if not Eventcategoryprint3.FindFirst() then begin
Categoryprint.Reset();
Categoryprint.SetRange(code, Eventcategoryprint3.No);
IF not Categoryprint.FindFirst() THEN begin
Message('categoryprint%1', Categoryprint.code);
Eventcategoryprint3.Init();
Eventcategoryprint3.Type := Eventcategoryprint3.Type::Template;
Eventcategoryprint3.No := rec."Template No.";
Eventcategoryprint3.code := Rec.code; //See this if this ok or Generate new one
Eventcategoryprint3.Insert();
end;
end;
end;
Eventcategoryprint3.Reset();
page.Run(50001, Eventcategoryprint3);//
end;
|
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,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156