Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Post-processed method ...
Finance forum
Answered

Post-processed method on set-based data entity

Posted on by 25

Hi,

I have import data entity with no row-processing-logic, "Set-based processing" = true. So import is really fast, importing to my customized table, working fine.

But at the end, when everything is already inserted to table, I want to run some "postprocessing" logic. When I have some other data entity with "Set-based processing" = false, I'm usually overriding "postTargetProcess( )" method and it's working. But in case of "Set-based processing" = true this method is not called at all.

Is there any way how to run my code after importing all records with "Set-based processing" = true data entity? 

Thanks

Regards,

Ales

  • Rich Profile Picture
    Rich 217 on at
    Post-processed method on set-based data entity

    Found the solution, using post-handler method:

    [PostHandlerFor(classStr(DmfEntityWriter), methodStr(DmfEntityWriter, write))]

    We're finding that DMFExecutionStatusHelper::GetExecutionSummaryStatus always returns Executing within this Post-Handler method. Can anyone please advise whether that's an inappropriate judge of when the processing to target is complete? We're trying to record an overall journal status to identify any potential "missing" lines (i.e. 10 line input file results in a 9 line journal: we'd like to put a clear identifier on the journal header), so only want to update the header when all lines have been processed

    Update: we've used copyCustomStagingToTarget with a join to the target table: if all staging rows exist in target & no staging rows report an error, the journal header can considered a success.
  • ArunGarg Profile Picture
    ArunGarg 3,924 on at
    RE: Post-processed method on set-based data entity

    Now I found the solution.

  • Sukrut Parab Profile Picture
    Sukrut Parab 71,645 Moderator on at
    RE: Post-processed method on set-based data entity

    Hi Arun ,

    Please create a new thread for your question.

  • ArunGarg Profile Picture
    ArunGarg 3,924 on at
    RE: Post-processed method on set-based data entity

    Like i have xml file which contain two Journal line so in this case  how we can  iterate Target and staging data in this method.

    Please suggest

  • Verified answer
    AlesDokoupil Profile Picture
    AlesDokoupil 25 on at
    RE: Post-processed method on set-based data entity

    Found the solution, using post-handler method:

    [PostHandlerFor(classStr(DmfEntityWriter), methodStr(DmfEntityWriter, write))]

       public static void DmfEntityWriter_Post_write(XppPrePostArgs args)

       {

           DMFDefinitionGroupExecution  _dmfDefinitionGroupExecution = args.getArg('_definitionGroupExecution');

           // come code to iterate target table records exists joined from staging

       }

    This post-handler is called when data are imported to the staging and staging lines are set TransferStatus::Completed. It will probably also work in case of "Set-based processing" = NO (but for that case I would rather use PostTargetProcess( ) method as it's more clean from my POV).

    I have also found the connection between staging and target table, as primary key is the same in both cases, so just iterating target table records with exists join on staging based on primary key + execution ID + definitionGroup.

    But one important note: this method is called for all entities, so you have to switch at the beginning, if it's "your" entity:

    str callerEntity = dmfDefinitionGroupExecution.EntityXMLName;
    ;

    switch (callerEntity)
    {

    case 'ASMyImportEntity':

    // something

    break;

    }

    Thanks for your help, your idea at the beginning was inspiring.

    Ales

  • AlesDokoupil Profile Picture
    AlesDokoupil 25 on at
    RE: Post-processed method on set-based data entity

    Hi Sukrut, thanks for reply.

    this copyCustomStagingToTarget( ) is importing records from Staging to target table. But I don't want to implement this set-based copying. And I can't call super( ) in copyCustomStagingToTarget( ) and then process - get compilation error.

    Basically, I just want to let framework do everything and just process some (not all) of target records at the end of import. Something like PostTargetProcess( ) method in case of Set-based processing" = true. 

    Thanks.

  • Sukrut Parab Profile Picture
    Sukrut Parab 71,645 Moderator on at
    RE: Post-processed method on set-based data entity

    Use copyCustomStagingToTarget instead. This one is called during set based processing.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

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,552 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,552 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans