Forum Discussion

derowe's avatar
derowe
New Contributor
7 years ago

Need to remove leading zeros from Property before used as input to service

Testing a CreateOrder SOAP service which returns an order number with leading zeros

e.g. 0000133456

 

This is input to GetOrder service which does not take leading zeros.  Using Property/Property transfer step to

read property into the GetOrder service but need to remove the leading zeros from the property

 

What is the best way to do this?

a. Is there a way to remove leading zeros in Property Transfer step

b. Can I remove leading zeros in the field input of GetOrder SOAP service?

 

Call in GetOrder Service looks like this

${InternalOrderNumber Property Transfer#InternalOrderNumber}

2 Replies

  • derowe's avatar
    derowe
    New Contributor

    Another approach which worked for the field input

     

    ${=context.expand('${InternalOrderNumber Property Transfer#InternalOrderNumber}') as int}

  • avidCoder's avatar
    avidCoder
    Super Contributor

     

    You get the property value of this :- ${InternalOrderNumber Property Transfer#InternalOrderNumber}

     

    And store to String and apply any of the below approach:-

     

    1. Using java/groovy regex

     

    String s = "000004DR"
    
    String fvalue = s.replaceFirst("^0*", "")
    
    log.info fvalue
    
    //It will pint like this:-
    
    Fri Mar 09 11:46:06 IST 2018:INFO:4DR

    2. Using StringUtils class of apache

     

    //For this you need to import
    
    import org.apache.commons.lang3.StringUtils
    
    String fvalue = StringUtils.stripStart("000004DR","0")
    
    log.info fvalue
    
    //it will also print like this:-
    
    Fri Mar 09 11:47:36 IST 2018:INFO:4DR

    Hope, This helps you out.

     

    You like the reply. Learn how to give kudos to author.