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

Question

Question

Microsoft Copilot says it knows LFForm object

asked on November 5, 2024

As someone who doesn't know JS, I was messing around with Copilot and asked it if it knew the LFForm object.

I asked it to give me some code using regex and using the LFForm object to capitalize the first letter of user input in a field and it returned this:

$(document).ready(function() {
    // Assume the field you want to target has the ID 'FieldName' (replace with your actual field ID)
    var fieldId = 'FieldName';

    // Add an event listener for when the user inputs data
    LFForm.OnChange(fieldId, function() {
        var value = LFForm.GetFieldById(fieldId).value;

        // Use regex to capitalize the first letter of each word
        value = value.replace(/(?<!\S)([a-z])/g, function(match) {
            return match.toUpperCase();
        });

        // Set the modified value back to the field
        LFForm.SetFieldById(fieldId, value);
    });
});

with an explanation as to what it means.

To someone without the JS skill, this seems like it could be additional help.

I was surprised that AI has trained on this Laserfiche technology.

0 0

Replies

replied on November 5, 2024

Yes, most the major AI models seem to have ingested both our online documentation and the public version of Answers, so you should be able to get answers to JS and SDK coding questions.

Worth noting that we've seen AI models confidently make up things that look real but do not actually exist in the product.

5 0
replied on November 6, 2024 Show version history

Looking at that code, it definitely has the structure correct but it is unfortunately using the API wrong. I'd be interested in seeing what link it referenced there, I couldn't get copilot to give me a link and when it finally did it was a link that didn't exist (and referenced LF10)

If it referenced the latest documentation site, it would have much better knowledge and could hopefully understand a bit more how to use the functions, the structure of the parameters required, and their outputs. I am currently working on more of a user guide approach to the current LFForm object documentation that should be able to drive AI to provide more helpful and accurate answers to scripting questions and working with the new form designer.

For comparison, the actual code for the provided example would look like this:
 

// Assume the field you want to target has the ID 'FieldName' (replace with your actual field ID)
var fieldId = { variableName: 'FieldName' }';

// Add an event listener for when the user inputs data
LFForm.onFieldChange(fieldId, function() {
    var value = LFForm.getFieldValues(fieldId);
    // Use regex to capitalize the first letter of each word
    value = value.replace(/(?<!\S)([a-z])/g, function(match) {
        return match.toUpperCase();
    });
    // Set the modified value back to the field
    LFForm.setFieldValues(fieldId, value);
});

 

4 0
replied on November 7, 2024

Ya I can't get it to only use that specific page, it will find classic form examples and other javascript examples and combine them all into a result that doesn't work haha

0 0
replied on November 5, 2024

I've used it for a couple of things, and it has done a decent job. You can also use Copilot to write SQL queries against the various Laserfiche databases. You have to give it some detail as to the tables and columns, but it works fairly well. Not as well as the LFForm Object since it has documentation on the web.

2 0
replied on November 6, 2024

Obligatory notice for other readers: Read-Only queries. Running SQL queries that modify Laserfiche application databases outside of those publicly documented and approved by us on the Support site, in product docs, etc., or as directed by Laserfiche Support, is not supported.

Please especially do not do something like ask your LLM of choice for a SQL query to "fix" a stuck Forms process instance, run it, and then open a support case asking for help fixing your broken Forms database that now has inconsistent internal state.

4 0
replied on November 6, 2024

All good points.

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

Sign in to reply to this post.