Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

IM: Totals by document

Posted on by 769

Hi,

 I’m looking for help how to calculate totals of documents from the flat file using vb script of the Integration Manager. Need to set the document type based on the total: If Total <0 then SourceField = “Return” else SourceField = “Invoice”.Anybody’s done something like that? 

Thank you in advance,

Oleg.

 

*This post is locked for comments

  • Richard Whaley Profile Picture
    Richard Whaley 25,195 on at
    Re: Re: Re: IM: Totals by document

    Well I missed that part in the first post about adding up the detail lines.  You can use the detail lines to create the header records if they have the necessary information.  Group the lines in IM by the document number and have it sum the extended prices for you.

  • olegvi Profile Picture
    olegvi 769 on at
    Re: Re: IM: Totals by document

    Thank you Richard,

     You are correct, I’m trying to import the batch of sales transactions from the flat file that contains only line items (no headers). I’m dynamically creating header records by sorting and grouping the records while creating a Header query. I then need to dynamically sum up the line item amounts to figure out whether the total documents is positive or negative and based on that set the document type. I was hoping somebody may have developed a script that sums up the line items and passes the total to the Document Type field.

    Regards,

    Oleg.

     

  • Richard Whaley Profile Picture
    Richard Whaley 25,195 on at
    Re: IM: Totals by document

    You have a lot more to do than just set the document type.

    Your post was not clear but I am assuming you are trying to import sales transactions using integration manager.  You will need to not only change the document type but also change the value of the documents.  See, GP stores all documents with positive numbers.  So the total of a Return loaded in GP is a positive number.

     The integration manager has the ability to run scripts against fields.  Set the source of the Document Type field to Script and then open the details area where you can write the script you need.  There are a number of sample scripts, including one that sets a value of a field based on the contents of the source document.  Just what you need.

    However, if your source documents (header and lines) have negative numbers on returns, you will need to create a formula for each value and take the Absolute value of the field or multiply it by -1 when appropriate to get positive values.

    Check the sample scripts.  I am sure the syntax on this is not 100% accurate but the lines should read something like

    If SourceField(type)='RETURN then CURRENTFIELD = SourceField(lineunitprice) * -1;

    or

    IF SourceField(mytotal)<0 then CURRENTFIELD = SourceField(lineunitprice) * -1 else CURRENTFIELD = SourceField(lineunitprice);

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

Featured topics

Product updates

Dynamics 365 release plans