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 :
Dynamics 365 Community / Forums / Finance forum / Post-processed method ...
Finance forum

Post-processed method on set-based data entity

(0) ShareShare
ReportReport
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

  • Sukrut Parab Profile Picture
    71,741 Moderator on at

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

  • AlesDokoupil Profile Picture
    25 on at

    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.

  • Verified answer
    AlesDokoupil Profile Picture
    25 on at

    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

  • ArunGarg Profile Picture
    3,932 on at

    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

  • Sukrut Parab Profile Picture
    71,741 Moderator on at

    Hi Arun ,

    Please create a new thread for your question.

  • ArunGarg Profile Picture
    3,932 on at

    Now I found the solution.

  • Rich Profile Picture
    396 on at

    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.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

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

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans