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

Question

Question

How to Assign via SDK the Cutoff Instruction Name to a document

asked on April 8, 2020

The current activity Set Record Management Properties doesn't allow the use of token. So I try to assign via SDK Retention Schedule and Cutoff Instruction at the document level (not folder).

I found how to assign the Retention Schedule (via GetRecordProperties) but at the document level I can't find how to assign via SDK the Cutoff Instruction Name. Any idea ???

1 0

Answer

SELECTED ANSWER
replied on April 9, 2020

I dug through the SDK docs and think I've figured out what's going on. Laserfiche 10.4 introduced a set of features we collectively call "Flexible Records Management".

Flexible Records Management

Laserfiche Records Management has been updated to enable greater organizational flexibility in how records are handled, while still enforcing security restrictions to help them meet their compliance needs. Cutoff and retention policies can now be assigned directly to any entry in the repository, without needing to be located within record series. In addition, holds (previously called freezes) can be placed on any entry in the repository, regardless of its folder structure or whether it is a record.

I recall the previously documents could only inherit their cutoff criteria from the parent record folder/series. Because the last released version of the SDK is 10.2, it and its documentation do not include the new Flexible RM features. (SDK 10.4 coming soon).

However, Workflow 10.4+ SDK Script activities already load the RepositoryAccess (RA) 10.4 library by default, which does include the property you need. In short, the RecordProperties class now has a CutoffCriterionID property just as RecordSeriesProperties does. See sample code snippet below, which I verified successfully builds. Note that I had to explicitly add a using statement for Laserfiche.RepositoryAccess.Records namespace.

namespace WorkflowActivity.Scripting.SDKScript
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
    using Laserfiche.RepositoryAccess.Records;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : RAScriptClass104
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {
            // Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
            DocumentInfo DocInfo = new DocumentInfo(this.BoundEntryId, this.RASession);
            RecordProperties RecProps = DocInfo.GetRecordProperties();
            int cutoffId = 1; //ID of the cutoff criterion to apply to the record
            RecProps.CutoffCriterionId = cutoffId; //Sets the ID of the cutoff criterion of the represented record
            RecProps.Save();
        }
    }
}

 

0 0

Replies

replied on April 9, 2020

Hi Sebastian,

I tracked down some code I wrote a few years ago for a similar purpose. It triggers cutoff events at the document level.  Hopefully it's close enough be helpful.

namespace WorkflowActivity.Scripting.CutoffEventSetterSDKScriptAlternate
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
    using Laserfiche.RepositoryAccess.Records;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class CutoffEventSetter : RAScriptClass100
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {
            // Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session

            // Get the record folder containing the entry and its properties object
            DocumentInfo DocInfo = new DocumentInfo(this.BoundEntryId, this.RASession);
            string DocIsRecord = DocInfo.IsRecord.ToString();
            //this.MsgBox(DocIsRecord);
            RecordProperties RecProps = DocInfo.GetRecordProperties();

            // Create EventDateTime using EventDate since the SetEventDate method needs a DateTime object
            string EventDate = GetTokenValue("RetrieveFieldValues_Cutoff Date").ToString();
            DateTime EventDateTime = Convert.ToDateTime(EventDate);

			// Set the event date and save the record properties
            RecProps.TriggerDate = EventDateTime;
            RecProps.Save();
        }
    }
}

 

1 0
replied on April 9, 2020

Thanks for your help, that is a great code but what I try to achieve is to assign dynamically a cutoff at the document level not the trigger date so far the only way I can do it is by updating the cofId in the Toc table, I can't believe there is not a way with the sdk to do the same. 

0 0
SELECTED ANSWER
replied on April 9, 2020

I dug through the SDK docs and think I've figured out what's going on. Laserfiche 10.4 introduced a set of features we collectively call "Flexible Records Management".

Flexible Records Management

Laserfiche Records Management has been updated to enable greater organizational flexibility in how records are handled, while still enforcing security restrictions to help them meet their compliance needs. Cutoff and retention policies can now be assigned directly to any entry in the repository, without needing to be located within record series. In addition, holds (previously called freezes) can be placed on any entry in the repository, regardless of its folder structure or whether it is a record.

I recall the previously documents could only inherit their cutoff criteria from the parent record folder/series. Because the last released version of the SDK is 10.2, it and its documentation do not include the new Flexible RM features. (SDK 10.4 coming soon).

However, Workflow 10.4+ SDK Script activities already load the RepositoryAccess (RA) 10.4 library by default, which does include the property you need. In short, the RecordProperties class now has a CutoffCriterionID property just as RecordSeriesProperties does. See sample code snippet below, which I verified successfully builds. Note that I had to explicitly add a using statement for Laserfiche.RepositoryAccess.Records namespace.

namespace WorkflowActivity.Scripting.SDKScript
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using Laserfiche.RepositoryAccess;
    using Laserfiche.RepositoryAccess.Records;

    /// <summary>
    /// Provides one or more methods that can be run when the workflow scripting activity is performed.
    /// </summary>
    public class Script1 : RAScriptClass104
    {
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {
            // Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
            DocumentInfo DocInfo = new DocumentInfo(this.BoundEntryId, this.RASession);
            RecordProperties RecProps = DocInfo.GetRecordProperties();
            int cutoffId = 1; //ID of the cutoff criterion to apply to the record
            RecProps.CutoffCriterionId = cutoffId; //Sets the ID of the cutoff criterion of the represented record
            RecProps.Save();
        }
    }
}

 

0 0
replied on April 9, 2020

Thanks Samuel, that is exactly what I was looking for.

1 0
replied on April 9, 2020

Glad to be of assistance!

0 0
replied on April 9, 2020

I have a Version 10.4.2 By  default it use RAScriptClass102 if I change to 104 it doesn't compile where are the newest dll ?

 

2020-04-09_1802.png
0 0
replied on April 9, 2020

Strange. Are you sure Workflow is on 10.4.2, not only Laserfiche Server? I'm fairly certain Workflow 10.4.2 should use RAScriptClass104 by default.

Here's how to double check WF Designer and Server versions:

Aside from that, if Workflow really is on 10.4+ you might be able to manually change the RA version.

Remove RepositoryAccess from References and then re-add Version 10.4.0.0 from the GAC.

I recall that the CutoffCriterionId property didn't auto-complete for me even on RA 10.4. However, when I intentionally misspelled it, the build failed, so it's definitely a valid prop.

0 0
replied on April 9, 2020

I have the same version on Laserfiche.Workflow.Service, but it reference a 10.2 library.

It doesn't find laserfiche.repo so I find it by browsing the same place but when I arrive in the right folder even if it filter by exe and dll it didn't show and I cant select the 10.4.

That is so weird...

2020-04-09_1926.png
2020-04-09_1933.png
2020-04-09_1933_001.png
2020-04-09_1935.png
0 0
replied on April 9, 2020

The Problem was the workflow come from a 10.2 env so and it keeps sdk version. Thanks again samuel.

1 0
replied on April 9, 2020

So you've got it working now?

0 0
replied on April 10, 2020

Yes it works as expected thanks Samuel.

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

Sign in to reply to this post.