Skip to main content

Notifications

Business Central forum
Suggested answer

Want to Hide Confirmation message when my data is importing from configuration package

Posted on by 60
Hi Experts,

I am facing issue with configuration package. I have insert GuiAllowed true for case that if someone is changing my Link-with Erp boolean field from Project Page then it shoes the confirm message which is working fine. But if I import bulk data configuration package then it should not ask for confirmation message. So, the problem is that if I import bulk data from configuration package then it shows the confirm message which it should not show. How can I fix it.

P.S: The Link with Erp field is not able to be modified because this field is coming from Dependencies so I can not change it or modify it. Please see the below attachments for verification.


Code: 
Written in Codeunit:
[EventSubscriber(ObjectType::Table, Database::"Job", 'OnAfterValidateEvent', "Link With BuilderMt", true, true)]
    local procedure JobLinkWithErpCheck(var Rec: Record "Job"; var xRec: Record Job)
    var
        JsonString: Text;
        IsSuccessCode: Boolean;
        JobTaskRec: Record "Job Task";
        Cnfrm: Boolean;
    begin
        if Rec."Link With BuilderMT" <> xRec."Link With BuilderMT" then begin
            if GuiAllowed() then begin
                Cnfrm := Confirm('Are you sure you want to change link with the ERP?', false);
            End
            else begin
                Cnfrm := true;
            end;
            if Cnfrm then begin
                if rec."Link With BuilderMT" = true then begin
                    JsonString := JobCodeunit.CreateJobJson(Rec);
                    IsSuccessCode := JobCodeunit.CreateJobInErp(JsonString);
                    if IsSuccessCode = true then begin
                        JobTaskRec.SetRange("Job No.", Rec."No.");
                        if JobTaskRec.FindSet() then begin
                            REPORT.Run(REPORT::"ArmCreateJobTaskInERPRep", false, false, JobTaskRec);
                        end;
                    end;
                end;
            end
            else begin
                Error('');
            end;
        end;
    end;

Configuration Package Behaviour:
 
 
After importing and apply package then it shows this confirmation message which it should not
 
I want it to show message on Project page only where I am Modifying the record.

Please tell me the solution.

Thanks.
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 69,202 Super User 2024 Season 2 on at
    Want to Hide Confirmation message when my data is importing from configuration package
    Or you can add another field, such as IsConfigurationPackage, with a default value of false.
    Set it to true when importing from Configuration Package, which does not affect the code on the table and can achieve your goal.
     
    Just an idea, hope this helps.
    Thanks.
    ZHU
  • MA-22070947-0 Profile Picture
    MA-22070947-0 60 on at
    Want to Hide Confirmation message when my data is importing from configuration package
    Thanks Zhu and KasparsSemjonovs for your thoughtful answers but removing the field validation won't be a good option cause this field is linked with other processes.
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 69,202 Super User 2024 Season 2 on at
    Want to Hide Confirmation message when my data is importing from configuration package
    When you import through the Configuration Package, it is true, not false, because it is also imported from the page (BC UI).
    If you are importing via a Web Service or API, this is false.
    Of course you can skip the OnValidate trigger using the method mentioned by KasparsSemjonovs.
    More detail: Dynamics 365 Business Central: Can we skip/ignore field validation errors?
     
    Hope this helps.
    Thanks.
    ZHU
  • Suggested answer
    KasparsSemjonovs Profile Picture
    KasparsSemjonovs 3,692 Super User 2024 Season 2 on at
    Want to Hide Confirmation message when my data is importing from configuration package
    Open Fields in Configuration Package for this table.
    Then take out the Validate field checkmark for this field. This way, the validation will be skipped, and the confirmation message will not be shown. (of course it also doesn't do any other validations or filling in other fields if the onModify trigger is doing so, so gotta be carefult when skipping Validations)

  • MA-22070947-0 Profile Picture
    MA-22070947-0 60 on at
    Want to Hide Confirmation message when my data is importing from configuration package
    Hi ZHU,
     
    Thank you for your reply. 
    So the functionality of GuiAllowed did not work on Codeunit? And will it send GUIAllowed false when I am exporting the result by Configuration Package.
     
    Thanks.
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 69,202 Super User 2024 Season 2 on at
    Want to Hide Confirmation message when my data is importing from configuration package
    How about writing this control in the trigger of the Project page?
    This will not have any impact on the Configuration Package.
     
    Hope this can give you some hints.
    Thanks.
    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,459 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,358 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans