Parker Software Ltd Homepage
Forum Home Forum Home > ThinkAutomation Business Process Automation > Scripting
  New Posts New Posts RSS Feed - Extract field script help
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Extract field script help

 Post Reply Post Reply
Author
Message
dkdaye View Drop Down
New User
New User


Joined: 30 Apr 2016
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote dkdaye Quote  Post ReplyReply Direct Link To This Post Topic: Extract field script help
    Posted: 18 Jul 2019 at 6:02pm
First, thanks in advance for any help.

I am not a VB (or any kind of programmer) but I we have been using email2db and ThinkAutomation for many years and a new vendor is causing me grief in that they are sending various types of emails for parsing that need additional work.

What I am trying to do is look at a particular field for a certain piece of information 'LF COLD'. If it has that entry the field should extract 'LF COLD' but for anything else in this field it should say 'LF HOT'. I have been pulling my remaining hair out looking at if and instr statements with no luck.

I have tried so much but I either it fails 'OBJECT var is "Nothing"' or it passes but does not work.


Sub Main()
    ' commands start here
    If InStr(ThinkAutomationMessage.Body,"Source")="LF COLD" Then
    ThinkAutomationMessage.ExtractedFields("Source").Value="LF COLD"
    Else
    ThinkAutomationMessage.ExtractedFields("Source").Value="LF HOT"
    End If
End Sub


Any help would be so appreciated.

Cheers.

Edited by dkdaye - 18 Jul 2019 at 6:03pm
Back to Top
parkersoft-nick View Drop Down
Admin Group
Admin Group
Avatar
Lead Developer - ThinkAutomation

Joined: 28 Dec 2015
Location: UK
Points: 130
Post Options Post Options   Thanks (0) Thanks(0)   Quote parkersoft-nick Quote  Post ReplyReply Direct Link To This Post Posted: 24 Jul 2019 at 4:51am
I think it is your use of InStr and the way you are assigning to the extracted field that is not working.

Try the below:

If you are using the script action inside 'Trigger Actions':

Sub Main()
    ' commands start here
Dim MessageBody As String

MessageBody = ThinkAutomationMessage.Body

If InStr(MessageBody, "LF COLD") > 0 Then
    FIELDS_Value("Source") = "LF COLD"
Else
    FIELDS_Value("Source") = "LF HOT"
End If

End Sub

If you are using an Extract Script on the extracted field

Sub Main()
    ' commands start here
    Dim MessageBody As String

    MessageBody = ThinkAutomationMessage.Body

    If InStr(MessageBody, "LF COLD") > 0 Then
        ThinkAutomationExtract = "LF COLD"
    Else
        ThinkAutomationExtract = "LF HOT"
    End If
End Sub




Edited by parkersoft-nick - 24 Jul 2019 at 4:55am
Nick Proud - Parker Software

Software Development Lead -ThinkAutomation
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.078 seconds.