Genesys Cloud - Main

 View Only

Sign Up

Expand all | Collapse all

How can I add a character in the middle of a string variable ?

  Thread closed by the administrator, not accepting new replies.
  • 1.  How can I add a character in the middle of a string variable ?

    Posted 02-10-2021 04:57
    No replies, thread closed.
    Hi,

    In Architect, I want to add character (exemple %20) in the middle of a string variable created in Architect.

    I don't know which expression I have to use.

    For example, the variable value is : "123456" (entered by the caller), I want to change it through Architect expressions by adding "%20" in the middle of that variable to be "123%20456".

    Any help please ?

    Thank you in advance.
    #Implementation
    #Integrations
    #PlatformAdministration


  • 2.  RE: How can I add a character in the middle of a string variable ?

    Posted 02-10-2021 10:35
    No replies, thread closed.
    Will the value in the variable always be 6 alphanumeric characters in length?

    ------------------------------
    Dan Fontaine
    ConvergeOne, Inc.
    ------------------------------



  • 3.  RE: How can I add a character in the middle of a string variable ?

    Posted 02-10-2021 10:40
    No replies, thread closed.
    Hi Dan,

    Thanks for your reply. It will be just numeric (exemple: 123456) entered by the callers.
    But the length can be at least 3 digits and max 6 digits.

    Thank you.

    ------------------------------
    Mostafa Oudderhem
    Coverage-Communication
    ------------------------------



  • 4.  RE: How can I add a character in the middle of a string variable ?

    Posted 02-10-2021 10:45
    No replies, thread closed.
    Okay, so do you want the %20 to be to the left or right of the middle for values with an odd number digets? For example,

    1%2023 or 12%203
    12%20345 or 123%2045

    ------------------------------
    Dan Fontaine
    ConvergeOne, Inc.
    ------------------------------



  • 5.  RE: How can I add a character in the middle of a string variable ?

    Posted 02-10-2021 10:54
    No replies, thread closed.
    Hi Dan,

    It should always be after the third digit when starting from the right to left (only for numbers with more than 3 digits length).

    Also, it is not necessary to add this character if numbers are less that 3 digits length (example 7, 27, 103...etc.)

    Thank you.

    ------------------------------
    Mostafa Oudderhem
    Coverage-Communication
    ------------------------------



  • 6.  RE: How can I add a character in the middle of a string variable ?

    Posted 02-10-2021 11:36
    No replies, thread closed.
    I think this should help:

    Length(Task.LoanAmount) > 3 ? Left(Task.LoanAmount,3) + "%20" + Substring(Task.LoanAmount,3,3) : Task.LoanAmount

    Where the above expression is an expression in an Update Data block.

    For my example expression above, the variable that is holding the value is Task.LoanAmount. So you could substitute your variable name in for Task.LoanAmount.

    The first part of the expression tests the length to see if we need to insert "%20". If the length is greater than 3, for example "1234" or "123456", then we take the first three characters of the string, add "%20", and then add the remaining part of the string up to 3 additional characters.

    So, "1234" would turn into "123%204".

    If the length is not greater than 3, then we leave the value as-is. For example, "123" -> "123".

    If, in the future, you decide to change the allowed max length of the string to a value greater than 6, you will need to change the expression.

    ------------------------------
    Dan Fontaine
    ConvergeOne, Inc.
    ------------------------------



  • 7.  RE: How can I add a character in the middle of a string variable ?

    Posted 02-10-2021 11:53
    No replies, thread closed.
    Hi Dan,

    Many thanks for your help, I really appreciate it.

    Just one more thing, the "%20" should always be added at the fourth position when starting from right to left, for example, the value "1234" sould be "1%20234"

    May be I need to change this expression:

    Length(Task.LoanAmount) > 3 ? Left(Task.LoanAmount,3) + "%20" + Substring(Task.LoanAmount,3,3) : Task.LoanAmount

    To :

    Length(Task.LoanAmount) > 3 ? right(Task.LoanAmount,3) + "%20" + Substring(Task.LoanAmount,3,3) : Task.LoanAmount

    Thank you.

    ------------------------------
    Mostafa Oudderhem
    Coverage-Communication
    ------------------------------



  • 8.  RE: How can I add a character in the middle of a string variable ?

    Posted 02-10-2021 11:57
    No replies, thread closed.
    See, you got it! 

    That should work (just note that right should be Right).


    ------------------------------
    Dan Fontaine
    ConvergeOne, Inc.
    ------------------------------



  • 9.  RE: How can I add a character in the middle of a string variable ?

    Posted 02-10-2021 12:02
    No replies, thread closed.

    Slight tweak to to just add the rest of the string, however long it is, at the end.

    Length(Task.LoanAmount) > 3 ? Left(Task.LoanAmount,3) + "%20" + Substring(Task.LoanAmount,3,Length(Task.LoanAmount)-3) : Task.LoanAmount



    ------------------------------
    Melissa Bailey
    Genesys - Employees
    ------------------------------



  • 10.  RE: How can I add a character in the middle of a string variable ?

    Posted 02-10-2021 12:42
    No replies, thread closed.
    Hi Melissa,

    Thanks for your reply.

    by using this expression, when the caller dial 7612 it is converted to : "612%202". I need to be "7%20612".

    The expression applied is: Length(Task.LoanAmount) > 3 ? Righ(Task.LoanAmount,3) + "%20" + Substring(Task.LoanAmount,3,Length(Task.LoanAmount)-3) : Task.LoanAmount

    Any idea ?

    Thank you


    ------------------------------
    Mostafa Oudderhem
    Coverage-Communication
    ------------------------------



  • 11.  RE: How can I add a character in the middle of a string variable ?

    Posted 02-11-2021 10:50
    Edited by Michael Steinke 02-11-2021 10:53
    No replies, thread closed.

    Oops, just re-read your post and see that you are working with caller entered, so my replace bit won't work, but hey, somebody might find the below useful for other purposes.


    It might be easier to use the Replace function.  Use and update data to take your String and create a new variable the has " " replaced with %20  You can use this to handle multiple replacements in the same string and you don't need to worry about what position in the string the space occurs

    Here's the Expression I used in an update statement to create a new variable from my Flow.QueueName variable:

    Replace(Flow.QueueName," ","%20")



    ------------------------------
    Mike Steinke
    Inflow Communications
    ------------------------------