Skip to main content

Notifications

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

skip itemid if there is an error returning from logic inside where sql statement

Posted on by 768

Hello,

I have written an sql qeury:

public void run()
{
    while select RecId from inventSum
        where inventSum.Closed == NoYes::No &&
              (inventSum.PostedQty   inventSum.Received - inventSum.Deducted   inventSum.Registered - inventSum.Picked > 0)
        join RecId,ItemId from inventTableExpanded_ICL
             where inventTableExpanded_ICL.ItemId == inventSum.ItemId
        join RecId from inventDim
            where inventDim.inventDimId == inventSum.InventDimId
        join inventLocationId, wMSLocationId from wmsLocationIntermediate_ICL
            group by inventTableExpanded_ICL.ItemId, wmsLocationIntermediate_ICL.InventLocationId, wmsLocationIntermediate_ICL.WMSLocationId
            where wmsLocationIntermediate_ICL.InventLocationId == inventDim.InventLocationId &&
                  wmsLocationIntermediate_ICL.WMSLocationId    == inventDim.wMSLocationId
    {
        
        //info(strfmt("%1 %2 %3 ",inventTableExpanded_ICL.ItemId, wmsLocationIntermediate_ICL.InventLocationId, wmsLocationIntermediate_ICL.WMSLocationId))
      
        wmsOnlineCountingServer = WmsOnlineCountingServer::constructItem(inventTableExpanded_ICL.itemId, wmsLocationIntermediate_ICL.InventLocationId,
                                                                               wmsLocationIntermediate_ICL.WMSLocationId,NoYes::Yes);
        wmsOnlineCountingServer.run();
        
    }
}

this logic:

wmsOnlineCountingServer = WmsOnlineCountingServer::constructItem(inventTableExpanded_ICL.itemId, wmsLocationIntermediate_ICL.InventLocationId,
                                                                               wmsLocationIntermediate_ICL.WMSLocationId,NoYes::Yes);
wmsOnlineCountingServer.run();

must be performed for each itemid retrieved by the query but for some itemids wmsOnlineCountingServer.run() returns exception and throws an appropriate infolog and of course my logic stops then. Is there any way to skip such itemids, show infolog and resume the logic with the next itemid? what is the approach should be if I'd like to implement such behavior?

Thanks in advance.

  • dark_knight Profile Picture
    dark_knight 768 on at
    RE: skip itemid if there is an error returning from logic inside where sql statement

    Many thanks. Worked for me:))

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: skip itemid if there is an error returning from logic inside where sql statement

    You can use a try-catch statement to handle the errors without ending your whole process.

    https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/dev-ref/xpp-exceptions

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans