You are viewing limited content. For full access, please sign in.

Question

Question

Assign Field Value inside a field group

asked on April 20, 2018

Hi,  Looking for some help here.  I'd like to be able to change the value on a particular field inside a large field group list.  I can't seem to find my way on how to accomplish that.  I have a For Each Value activity to scroll through all the Ticket List values.  In the For Each Value loop I have some other items to check the ticket number and value and search for the ticket, then determine if the ticket should be marked found or left missing.

How do I assign the specific value inside that group to I don't assign/replace/clear them all?

As you can see from the example below, there are 340+ field groups on this particular document.  If I want to adjust the values of the ticket status in group 100, how is that done?

 

0 0

Answer

SELECTED ANSWER
replied on April 20, 2018 Show version history

Ok, a update for update for you case

use script sdk activity

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports Laserfiche.RepositoryAccess

Namespace WorkflowActivity.Scripting.Updatefield2
    '''<summary>
    '''Provides one or more methods that can be run when the workflow scripting activity is performed.
    '''</summary>
    Public Class Script1
        Inherits RAScriptClass102
        '''<summary>
        '''This method is run when the activity is performed.
        '''</summary>
        Protected Overrides Sub Execute()
            'Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
            Dim objFieldValueCollection As FieldValueCollection = BoundEntryInfo.GetFieldValues()
            Dim lngIndex as Long = GetTokenValue("ForEachValue_Iteration")
            BoundEntryInfo.Lock(LockType.Exclusive)
            objFieldValueCollection("Color")(lngIndex-1) = "New value"
            BoundEntryInfo.Unlock()
            BoundEntryInfo.SetFieldValues(objFieldValueCollection)
            BoundEntryInfo.Save()
        End Sub
    End Class
End Namespace

 

and ready!!!

regards,

Marco.

0 0

Replies

replied on April 24, 2018

I have this working now.  Marco's code works fine.  My problem was that I was trying to update and change fields that were empty.  I'm not sure of a work around for that, but the script works!!  THANKS MARCO!!!

1 0
replied on April 24, 2018

Good news!!!

0 0
replied on April 20, 2018

Hi Ken,

Use sequence activity for update the value on a particular field inside a large field group list.

 

 

regards,

Marco.

0 0
replied on April 20, 2018

Great!  What does your Assign Field Value activity look like?

0 0
SELECTED ANSWER
replied on April 20, 2018 Show version history

Ok, a update for update for you case

use script sdk activity

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports Laserfiche.RepositoryAccess

Namespace WorkflowActivity.Scripting.Updatefield2
    '''<summary>
    '''Provides one or more methods that can be run when the workflow scripting activity is performed.
    '''</summary>
    Public Class Script1
        Inherits RAScriptClass102
        '''<summary>
        '''This method is run when the activity is performed.
        '''</summary>
        Protected Overrides Sub Execute()
            'Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
            Dim objFieldValueCollection As FieldValueCollection = BoundEntryInfo.GetFieldValues()
            Dim lngIndex as Long = GetTokenValue("ForEachValue_Iteration")
            BoundEntryInfo.Lock(LockType.Exclusive)
            objFieldValueCollection("Color")(lngIndex-1) = "New value"
            BoundEntryInfo.Unlock()
            BoundEntryInfo.SetFieldValues(objFieldValueCollection)
            BoundEntryInfo.Save()
        End Sub
    End Class
End Namespace

 

and ready!!!

regards,

Marco.

0 0
replied on April 20, 2018

You can use the FieldValueCollection class in the SDK to find and update the value for one row in the multi-value field group. For sample code, check out this Empower presentation, specifically slide 26 of the PPT and the SetMVFG_Click method in Dev_302.cs. Your code can scan the array of values for that field to find the one that has the ticket status you want. Then find the corresponding row number in the array returned by GetFieldRowNumbers. With this row number, you can find and update the other values in that group.

0 0
replied on April 20, 2018

Awesome. I will check that out and post the results.  On a side note, I'll know going in the iteration or row number that I want to change from the For Each Value activity.  Not sure if that helps.

0 0
replied on April 20, 2018 Show version history

If you know the item to update, you can apply the sdk script only.

In script code:

Dim lngIndex as Long = GetTokenValue("ForEachValue_Iteration") 

replace for

Dim lngIndex as Long = 100

 

regards,

Marco.

0 0
replied on April 20, 2018

Marco, sweet!!!  I will check out the presentation to understand then apply your code to test.

0 0
replied on April 20, 2018

ok, if this helps you with your problem, please select it as an answer.

 

best regards,

Marco.

0 0
replied on April 24, 2018

When I attempt this script and use a value in the range of groups on the document, I get this error and the script hangs: Property 'Chars' is ReadOnly

0 0
replied on April 24, 2018

I found the first issue I have.  I am trying to update a list field.  When I update a text field, no issues.

0 0
replied on April 24, 2018

This script doesn't seem to work for me.  I can change the FIRST field in any collection, but I can't seem to adjust the script to change the Ticket Status field which is the 4th field in the collection.  any scripting help would be much appreciated.

0 0
replied on April 24, 2018

Please, paste a screen of your template, and the code that you use.

0 0
replied on April 24, 2018

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports Laserfiche.RepositoryAccess

Namespace WorkflowActivity.Scripting.SDKScript3
    '''<summary>
    '''Provides one or more methods that can be run when the workflow scripting activity is performed.
    '''</summary>
    Public Class Script1
        Inherits RAScriptClass102
        '''<summary>
        '''This method is run when the activity is performed.
        '''</summary>
        Protected Overrides Sub Execute()
            'Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
            Dim objFieldValueCollection As FieldValueCollection = BoundEntryInfo.GetFieldValues()
            Dim lngIndex as Long = GetTokenValue("FEV_Iteration")
            Dim Status as String = "Missing"
            BoundEntryInfo.Lock(LockType.Exclusive)
            objFieldValueCollection("Ticket_Status")(lngIndex-1) = (Status)
            BoundEntryInfo.Unlock()
            BoundEntryInfo.SetFieldValues(objFieldValueCollection)
            BoundEntryInfo.Save()
        End Sub
    End Class
End Namespace

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.