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

Question

Question

Workflow token used by custom activity is not resolve to the value

asked on February 12

I created a sample custom activity to understand how it works.

 

it works well if I manually put value in my custom activity input, but if I choose a token from a previous workflow activity,. the toke is not resolve by the value, so the custom activity use the content of the input, mean the variable name. see by picture.

the custom activity do a rename of the starting entry

Yes I have set in the proxy generator the support Tokens

 

 

Is there something more to do toget this working, mean get the value of a previous activity token as normal workflow activity do.

here the sample code I used


namespace MonPremierProjet
{
    using Laserfiche.Custom.Activities;
    using Laserfiche.Workflow.ComponentModel;
    using Laserfiche.Custom.Activities.Design;
    using Laserfiche.RepositoryAccess;
    using LFSO90Lib;
   
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics;
    using System.ComponentModel;
    using System.Workflow.ComponentModel;
    using System.Drawing;
    using Laserfiche.Workflow.Activities;

    public class MonPremierProjetActivity : CustomSingleEntryActivity
    {
        private string userInput = "";
        public string UserInput
        {
            get { return this.userInput; }
            set { this.userInput = value; }
        }
        /// <summary>
        /// Called when the activity is run by the workflow server. Implement the logic of your activity in this method. 
        /// Access methods for setting tokens, getting token values, and other functions from the base class or the execution 
        /// context parameter. 
        /// </summary>
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            using (ConnectionWrapper wrapper = executionContext.OpenConnectionRA102())
            {
                Session session = (Session)wrapper.Connection;
                // Note: You must add the Laserfiche.RepositoryAccess reference to this project for this to work.
                // TODO: Your code here

               // DocumentInfo DI = Document.GetDocumentInfo(GetEntryInformation(executionContext).Id, session);
               //or the 2 next lines
                LaserficheEntryInfo entryInfo = this.GetEntryInformation(executionContext);
                DocumentInfo DI = Document.GetDocumentInfo(entryInfo.Id, session);                
                DI.RenameTo(this.UserInput);

            }
            return base.Execute(executionContext);
        }
    }
}

Any ideas

 

0 0

Answer

APPROVED ANSWER SELECTED ANSWER
replied on February 13 Show version history

Rene,

You must call the ResolveTokensInText method of the executionContext object to get the actual value of the token.  Here is a rewrite of your code...


protected override System.Workflow.ComponentModel.ActivityExecutionStatus Execute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext)
{
    using (ConnectionWrapper wrapper = executionContext.OpenConnectionRA102())
    {
        Session session = (Session)wrapper.Connection;
        LaserficheEntryInfo entryInfo = this.GetEntryInformation(executionContext);
        DocumentInfo DI = Document.GetDocumentInfo(entryInfo.Id, session);
        string newEntryName = this.UserInput;
        if (newEntryName.Contains("%"))
        {
            newEntryName = executionContext.ResolveTokensInText(newEntryName);
        }

        DI.RenameTo(newEntryName);
    }

    return base.Execute(executionContext);
}

 

1 0
replied on February 13

Thank you Cliff

I thought the workflow application does it before to pass the the token value to the activity.

Thanks for your help.

0 0

Replies

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

Sign in to reply to this post.