web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Create validation before click production order post button

(1) ShareShare
ReportReport
Posted on by 73
Hello all,
I want to create a validation when the post button is clicked. The validation is quite simple where I need to make sure all the data to be posted has a costcenter that is not 000.
 
 
so I made a custom coding like the following and it didn't give any effect, any advise?
    /// <summary>
    ///
    /// </summary>
    /// <param name=/sender/></param>
    /// <param name=/e/></param>
    [FormControlEventHandler(formControlStr(ProdJournalTransBOM, PostJournal), FormControlEventType::Clicked)]
    public static void PostJournal_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        ProdJournalBOM  prodJournalBOM;
        FormControl formButtonControl = any2Object(sender) as FormControl;
        FormDataSource formDatasource = formButtonControl.formRun().dataSource(tableStr(ProdJournalTable));
        ProdJournalTable prodJournalTable = formDatasource.cursor();
        while select prodJournalBOM
        while select prodJournalBOM
            where prodJournalBOM.JournalId == prodJournalTable.JournalId
            && ProdJournalType::Picklist == prodJournalTable.JournalType
        {
            DimensionAttributeValueSetItemView  dimensionAttributeValueSetItemView;
            DimensionAttribute                  dimensionAttribute;
            select dimensionAttributeValueSetItemView
                join dimensionAttribute
                where dimensionAttributeValueSetItemView.DimensionAttribute == dimensionAttribute.RecId
                && dimensionAttribute.Name == 'CostCenter'
                && dimensionAttributeValueSetItemView.DimensionAttributeValueSet == prodJournalBOM.DefaultDimension;
            if(dimensionAttributeValueSetItemView.DisplayValue == '000')
            {
                Error('CostCenter 000 dont alowed');
                throw Exception::Error;
            }
        }
    }
 
thank u
 
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    238,780 Most Valuable Professional on at
    It's possible - I'm pretty sure that are many validations in the standard code.
     
    But your code is at a wrong and it can't do the job. It runs after posting and it ignores the standard logic.
     
    The button is linked to ProdJournalPost menu item, which calls ProdJournalCheckPost class. There you can overide checkJournal(), for instance, to implement the validation. Not only it's the most logical place, but it'll support scenarios you forgot about, such as checking the journal without posting.
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    As Martin suggested you code doesn't work because this runs at super of clicked method.
     
    You need to either write this at before next in COC or you can check in standard, ProdJournalCheckPost class we have got lot of boolean methods like prerun(), checkjournal(), checktrans() etc which can be used for throwing the validation.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 514 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 390

#3
Adis Profile Picture

Adis 266 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans