Print Page | Close Window

Script for text to integer not working

Printed From: Parker Software Ltd
Category: ThinkAutomation Business Process Automation
Forum Name: Scripting Samples
Forum Description: We will post sample scripts here
URL: http://www.parkersoftware.com/forum/forum_posts.asp?TID=9417
Printed Date: 31 Mar 2020 at 1:00am
Software Version: Web Wiz Forums 11.05 - http://www.webwizforums.com


Topic: Script for text to integer not working
Posted By: bickell
Subject: Script for text to integer not working
Date Posted: 04 Feb 2020 at 12:52pm
I set up the following script to convert a field that comes in as text (either "Yes or "No")  to a value of  1 or 0 so that it can be written to a bit (boolean) field in MS SQL. 

The script does not work as written and I am not sure what I have done wrong.   When the value is "Yes" in the email, the database field that is mapped to this extracted value is being written as 0. 

Sub Main()
    ' commands start here
    ThinkAutomationExtract = ThinkAutomationExtract

    Dim PreviousASIString As String
    Dim prevASIBit As Integer
    PreviousASIString = ThinkAutomationExtract

    Select Case PreviousASIString
        Case "Yes"
            prevASIBit = 1
        Case "No"
            prevASIBit = 0
    End Select
    ThinkAutomationExtract = prevASIBit
End Sub

Any help would be appreciated.



Replies:
Posted By: bickell
Date Posted: 04 Feb 2020 at 1:29pm
Also tried the following, but still can't get the database field to update to 1. 

Sub Main()
    ' commands start here
    'ThinkAutomationExtract = ThinkAutomationExtract

    Dim PreviousASIString As String
    Dim prevASIBit As Integer

    PreviousASIString = ThinkAutomationMessage.ExtractedFields("PreviousASI").Value
    Call AddToLog("Extracted field value: " & PreviousASIString)

    Select Case PreviousASIString
        Case "Yes"
            prevASIBit = 1
        Case "No"
            prevASIBit = 0
    End Select
    ThinkAutomationExtract = prevASIBit
    Call AddToLog("Converted field value: " & ThinkAutomationExtract)
End Sub




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.05 - http://www.webwizforums.com
Copyright ©2001-2016 Web Wiz Ltd. - https://www.webwiz.co.uk