Parker Software Ltd Homepage
Forum Home Forum Home > ThinkAutomation Business Process Automation > Scripting > Scripting Samples
  New Posts New Posts RSS Feed - Script for text to integer not working
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Script for text to integer not working

 Post Reply Post Reply
Author
Message
bickell View Drop Down
New User
New User
Avatar

Joined: 11 Jun 2007
Location: Kansas City, MO
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote bickell Quote  Post ReplyReply Direct Link To This Post Topic: Script for text to integer not working
    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.
Back to Top
bickell View Drop Down
New User
New User
Avatar

Joined: 11 Jun 2007
Location: Kansas City, MO
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote bickell Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Liam View Drop Down
Admin Group
Admin Group
Avatar

Joined: 29 Jun 2011
Location: Stoke-on-Trent
Points: 263
Post Options Post Options   Thanks (0) Thanks(0)   Quote Liam Quote  Post ReplyReply Direct Link To This Post Posted: 09 Jun 2020 at 9:36am
Is the script actually working at this point?
I noticed your add to log action, is this showing that the item is being updated to 1 or 0?
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.05
Copyright ©2001-2016 Web Wiz Ltd.

This page was generated in 0.105 seconds.