Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

How to validate field name of a file to be imported via Dixif at the time of running source to staging table.

Posted on by

I have a processing group which uses a file which has a column company name.

Is there a way i can validate  if the filecompany name == curext() (company name user is logged into) before data is moved from source to staging.

Intent is to not allow data to be moved to staging if the company name of file being imported is not same as the company name user has logged into.

Thanks

Mav

  • Verified answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 Season 2 on at
    RE: How to validate field name of a file to be imported via Dixif at the time of running source to staging table.

    Hi Mav,

    You can't perform this validation on the staging table. The reason is that the import into the staging table is handled by SSIS to get an optimal performance. So, there is no AX logic executed at the stage where the file is being read and records imported in SQL directly.

    So, the only option here is indeed from staging to target.

    Or create additional logic that the file will be scanned before it will be picked up by the SSIS package.

  • Mav Profile Picture
    Mav on at
    RE: How to validate field name of a file to be imported via Dixif at the time of running source to staging table.

    My validation between staging to target is already working, but i thought why to have unncecessary records in staging itself & hence thought of building a solution which would refrain to insert recs which fail validation at staging itself.

    Thx for your guidance.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to validate field name of a file to be imported via Dixif at the time of running source to staging table.

    I think the validation happens between staging and target. Would that work for you? Otherwise you need to put your code in validateWrite of staging table. But that's against the standard way how entities, staging and validation works. I recommend sticking to the standard approach.

  • Mav Profile Picture
    Mav on at
    RE: How to validate field name of a file to be imported via Dixif at the time of running source to staging table.

    public boolean validateWrite()
    {
        if (this.Company != curext())
        {
            info("Validation failed data not imported");
            return false;
        }
    
        return true;
    }

    :-( The above code did not work as i see records inserted in staging table after i import the file using DIxif. Please note the company in file name is not the same as the company from where i am importing so ideally it should have not allowed to insert/update in teh staging table.

    Please suggest a fix.

  • Mav Profile Picture
    Mav on at
    RE: How to validate field name of a file to be imported via Dixif at the time of running source to staging table.

    Will use this.company != curext() & see if it works

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to validate field name of a file to be imported via Dixif at the time of running source to staging table.

    I think that the process runs asynchronously so it might not write to your infolog or debugger.

    But if you develop logic in validateWrite, there's no need to throw error (the standard pattern is return checkFailed("error message")). And the error message can be found in the execution log.

  • Mav Profile Picture
    Mav on at
    RE: How to validate field name of a file to be imported via Dixif at the time of running source to staging table.

    The requirement is same throw error when file company name column has a company name which != curext()

    So i followed your suggestion and in order to capture what will  file company name column look in runtime i added a test info message & put a debugger so that i can see what is type of file company name column & then replace my   file company name column   != curext() with that type from debugger.

    Hence after adding info test in insert/update & validate write & checking all the boxes of business validation & logic in processing group when i retried the import i was expecting my test info to show in the infolog , however unfortunately nothing got caught in debugger , also tested my debugger & realized that it is working fine.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to validate field name of a file to be imported via Dixif at the time of running source to staging table.

    But that was not your requirement, right? Did you try to implement the validation?

  • Mav Profile Picture
    Mav on at
    RE: How to validate field name of a file to be imported via Dixif at the time of running source to staging table.

    I did check my validateWrite() for my entity and wrote info("test") in there, change the procecssing group i.e. checked the box states run business validation , now when i run the dixif import i do not see info test

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to validate field name of a file to be imported via Dixif at the time of running source to staging table.

    I would start by trying to put such validation in the validateWrite() method of the entity.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans