Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

IM script to split a field witha delimiter

(0) ShareShare
ReportReport
Posted on by 390

I am looking for an IM script to split a source field that contains a delimiter (-).  The results will be used in two separate fields in GP.  The script should work similar to the "Text-To-Colum" feature in Excel.

Thanks,

Carlos

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: IM script to split a field witha delimiter

    Hello Carlos, I missed this post from you a long time ago but here is my suggestion to use in your integration manager. The code below evaluates the field being passed from the source and reads characters and passes them to sBefore and sAfter variables, at the end you choose which variable to pass to the CurrentField, use the script and modify accordingly, if its not too late let us know if it works.

    sFieldEvaluated = SourceFields("Datasource.Yourfield")

    sBefore = ""

    sAfter = ""

    sFlag = False

    Do While Len(sFieldEvaluated)>0

    sCharacter = Left(sFieldEvaluated, 1)

    If sCharacter <> "-" then

    if sFlag = False then

    sBefore = sBefore & sCharacter

    end if

    if sFlag = True then

    sAfter = sAfter & sCharacter

    end if

    End if

    if sCharacter = "-" then

    sFlag = True

    end if

    sFieldEvaluated = Right(sFieldEvaluated, Len(sFieldEvaluated)-1)

    Loop

    CurrentField = sBefore

    'or sAfter depending on the target field

  • Beat Bucher  GP Geek  GPUG All Star Profile Picture
    Beat Bucher GP Gee... 28,054 Super User 2024 Season 1 on at
    Re: IM script to split a field witha delimiter

    Hi Carlos,

    There is nothing that keeps you from using the same field twice for the input and output it to 2 different fields in GP... I vaguely remember there was some basic function that can be used to 'strip' off the content of a string field... that may do the job for you, but I'd have to check in the user manual since I don't have IM installed and it is quite a few years that I used it now.

    If you have (certainly) access to Customer source, you'll be able to grab the MS official Training guide for IM (course 8815A). It is based on GP 10, but the basic principles remain. I think chap. 4 should provide you ample details about the data manipulation.

    Good luck.

  • CIGARCIA Profile Picture
    CIGARCIA 390 on at
    Re: IM script to split a field witha delimiter

    Béat,

    Thanks for your reply.  The data is in a CSV file.  I guess I can prepare the data but I have staff that are not familiar with this process and mistakes could happen.  That's why I want IM to handle the split.  Do you know if IM offered a script to do the following:

    Given ABI0001-ARI0150 as my source, I want IM to bring AR0150 and put it in a destination field.  I can have IM truncate the source and put ABI0001 in a different destination field but I don't know how to make it do the same for the second part of my source (ARI0150),  Any help will be highly appreciated.

    Thanks,

    Carlos

  • Beat Bucher  GP Geek  GPUG All Star Profile Picture
    Beat Bucher GP Gee... 28,054 Super User 2024 Season 1 on at
    Re: IM script to split a field witha delimiter

    What is your data source ? an Excel file ? a CSV file ?

    if it's an Excel, it's easy to manage before the data gets uploaded with IM to GP... I can't remember IM offering much of scripting functions..

    My suggestion is to have the data prepared as much as possible before getting sourced / parsed by IM to avoid any splitting afterwards.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans