Jump to content

FieldChanged and FusionPro.Composition.composeThisRecord


Landisa

Recommended Posts

I have a form with a key file that can have multiple keys.

My goal is to add code prevent creating multiple copies of the form based on if the field has the same key as previous.

 

Example:

KEY1 KEY2

312456 103489

312456 504723

312456 654871

 

My form already turns on when it finds the field that matches it:

 if (Field("Letter_Code") == "010")
{
     FusionPro.Composition.SetBodyPageUsage("Letter_010", true);
 }

 

I was thinking of using the FieldChanged rule and composeThisRecord rule to help prevent creating multiple letters since they KEY1 is the one we are basing the code from even though we need both keys for different table pulls.

 

My code ended up being like:

    FusionPro.Composition.composeThisRecord = false;
   if (FieldChanged(Field(KEY1")))
   {
      FusionPro.Composition.composeThisRecord = true;
   }

 

OR

    if (FieldChanged(Field("KEY1")))
   {
      FusionPro.Composition.SetBodyPageUsage("Letter_010", true);
    }

 

However, when I run this code it turns the whole form unrenderable.

 

Am I using this code incorrectly?

Any suggestions?

 

If requested I can mock up a new file for viewing due to the sensitive nature of the form.

Edited by Landisa
Solved
Link to comment
Share on other sites

Instead of this:

 if (FieldChanged(Field("KEY1")))

You want this:

 if (FieldChanged("KEY1"))

 

 

This did the job!

Now is there anyway to get that form to preview using the code?

Runs beautiful on the server, just can't preview the form now.

Link to comment
Share on other sites

This did the job!

Now is there anyway to get that form to preview using the code?

Runs beautiful on the server, just can't preview the form now.

Well, in Preview, it's only actually processing a single record of data, so the "FieldChanged" will always return false, since there's no previously processed record to compare the current record's field value to.

 

This should work, though:

 if (FieldChanged("KEY1") || IsPreview())

Link to comment
Share on other sites

Well, in Preview, it's only actually processing a single record of data, so the "FieldChanged" will always return false, since there's no previously processed record to compare the current record's field value to.

 

This should work, though:

 if (FieldChanged("KEY1") || IsPreview())

 

Awesome! This works like a charm!

 

Mostly just need to make sure the fields are populating.

If the preview doesn't show the "FieldChanged" correctly but still runs on the server without issues, we are good to go!

 

Thanks again for the help! ^^,

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...