We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

<subdialog> Integer return value getting corrupt

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
vikas
Posts: 53
Joined: Wed May 13, 2015 7:46 pm

<subdialog> Integer return value getting corrupt

Post by vikas »

We are facing an issue with <subdialog>

In the subdialog a field has a value of 15.15. When it is returned to the calling module the value gets changed to 15.149999618530273.

Below is the section of code that calls the subdialog passing a few paramters. This subdialog returns a field called availableBalance. On displaying the value of availableBalance it shows as 15.149999618530273 instead of 15.15

Code: Select all

 <subdialog name="authorization" src="APICalls.xml">
			<param name="IVR_Name" expr="IVR_Name"/>
			<param name="IVR_type" expr="IVR_type"/>
			<param name="resServer" expr="resServer"/>
			<param name="wavServer" expr="wavServer"/>
			<param name="apiServer" expr="apiServer"/>
			<param name="apiName" expr="apiName"/>
			
			
			<filled>
				<log expr="'*****Returned from Authorization.xml'"/>
				<assign name="override" expr="authorization.override"/>
				<assign name="authToken" expr="authorization.authToken"/>
				<assign name="authTokenExpires" expr="authorization.authTokenExpires"/>
				<assign name="HTTPResponseCode" expr="authorization.HTTPResponseCode"/>
				<assign name="statusCode" expr="authorization.statusCode"/>
				<assign name="statusMessage" expr="authorization.statusMessage"/>
				
				<assign name="availableBalance" expr="authorization.availableBalance"/>
				<log expr="'*****availableBalance ===== ' + availableBalance"/>
Also below is the section of code from APICalls.xml that returns the value. Here the balance is displayed as 15.15 correctly.
but when it gets returned to the calling module the value gets changed to 15.149999618530273.

Can you please suggest why we are facing this issue? Thanks.

Code: Select all

<data name="getCardResponse" srcexpr="apiServer + '/card/' + cardToken" enctype="application/x-www-form-urlencoded" method="get" accept="application/json" headersexpr="JSON.stringify(headers)"/>
            <assign name="HTTPResponseCode" expr="getCardResponse$.status"/>
            <assign name="statusCode" expr="getCardResponse.status.code"/>
            <assign name="statusMessage" expr="getCardResponse.status.message"/>
            
           	<log expr="'*****HTTPResponseCode*****' + HTTPResponseCode"/>
          	<log expr="'*****status code*****' + statusCode"/>
            <log expr="'*****status message*****' + statusMessage"/>
            
            <if cond="getCardResponse.status.code == '200'">
            	<assign name="availableBalance" expr="getCardResponse.data.balance"/>
           		<assign name="pin" expr="getCardResponse.data.pin"/>
           		<assign name="activationStatus" expr="getCardResponse.data.activation.status"/>
           		<assign name="activationDate" expr="getCardResponse.data.activation.date"/>
           		<assign name="expirationStatus" expr="getCardResponse.data.expiration.status"/>
           		<assign name="expirationDate" expr="getCardResponse.data.expiration.date"/>
           		<assign name="authenticated" expr="true"/> <!-- Set authenticated to true -->
           		
           		<log expr="'*****Balance*****' + availableBalance"/>
          		<log expr="'*****Pin*****' + pin"/>
            	<log expr="'*****Activation status*****' + activationStatus"/>
            	<log expr="'*****Activation date*****' + activationDate"/>
            	<log expr="'*****expiration status*****' + expirationStatus"/>
            	<log expr="'*****expiration date*****' + expirationDate"/>
            	<log expr="'*****authenticated*****' + authenticated"/>
            
           		<return namelist="override authToken authTokenExpires cardToken availableBalance pin HTTPResponseCode statusCode statusMessage authenticated TRXNData orderStatus dateShipped actStatus actDate actRequired actResult csrTransfer transferReasonCode sendErrorEmail errorEmailMessage errorEvent"/>

vikas
Posts: 53
Joined: Wed May 13, 2015 7:46 pm

Re: <subdialog> Integer return value getting corrupt

Post by vikas »

I was able to fix the issue by appending ''+ as below. This fixed the issue.
<assign name="availableBalance" expr="''+getCardBalance.data.balance"/>

Post Reply