Jump to content

Assigning a value to a FusionPro Field in an OnRecordStart


Recommended Posts

I am trying to set the value of an existing field in the OnRecordStart rule.

I am having no success.

 

I am currently using this expression:

var size = "1440";
FindTextFrame("SquareInches").SetFieldValue = "size";

Right now I am hard coding the "1440" to eliminate variables. This will eventually be:

var size = (Field("pageHeight") * Field("pageWidth"));
FindTextFrame("SquareInches").SetFieldValue = "size";

I get no errors when I validate in FusionPro. But I can't get the value to appear in the Form Field in MarcomCentral. This has to be possible, I must be missing something simple.

 

Ideas?

Edited by Printing Partners
Link to comment
Share on other sites

I don't know about MarcomCentral but in FusionPro, "SetFieldValue" is not a property of a text frame.

 

If you're trying to override the value of the "size" field from your OnRecordStart rule, you can do that like this:

var NumberField = function (field) { return StringToNumber(Field(field)); }
var size = NumberField("pageHeight") * NumberField("pageWidth");
FusionPro.Composition.AddVariable('size', size);

 

Creating a text rule called "size" will also override the value of the "size" field:

var NumberField = function (field) { return StringToNumber(Field(field)); }
return NumberField("pageHeight") * NumberField("pageWidth");

 

If you're asking how to set the content of the "SquareInches" text frame in your template, you can do that like this:

var NumberField = function (field) { return StringToNumber(Field(field)); }
FindTextFrame("SquareInches").content = NumberField("pageHeight") * NumberField("pageWidth");

Link to comment
Share on other sites

Ste,

Thanks for the help. I finally realized I had the wrong function in "SetFieldValue".

 

I will try what you have shown me, but I don't think I can accomplish what I am trying to do. I was finally able to get it to populate the field, but I am still not getting the result I want.

 

I was hoping to "Pre-populate" a field so Marcom would pick it up for iForms pricing. I can change the value of the field, but it won't "pre-populate", meaning it won't show up in the field in the form, it will show up in the rendered PDF. As such iForms won't acknowledge the value I set.

 

I am not sure if the OnJobStart rule will give me a different result.

Link to comment
Share on other sites

I was hoping to "Pre-populate" a field so Marcom would pick it up for iForms pricing. I can change the value of the field, but it won't "pre-populate", meaning it won't show up in the field in the form, it will show up in the rendered PDF. As such iForms won't acknowledge the value I set.

First, this is really a MarcomCentral-specific question, which should be asked in the MarcomCentral sub-forum.

 

That said, I don't think what you're trying to do is possible. (And frankly, I'm not sure why you think it should be.) FusionPro has no knowledge of the MarcomCentral application, nor what its form looks like. And MarcomCentral, other than managing a repository of FusionPro templates, really has no knowledge about what's in those templates, especially in the JavaScript rules.

 

For the most part, at template preview time, all MarcomCentral does with FusionPro is write the data from its web form into a data file for FusionPro, then tells FusionPro to compose that data file with a particular template (DIF file). MarcomCentral does modify and add some CFG entries / job settings as well, but these don't somehow magically enable either program to really know much more about what the other is doing.

 

There is an HTML Form Definition (Web Collect) feature in FusionPro, which some online web-to-print systems utilize, and that does indeed allow you to define a default value for each field. Unfortunately, though, MarcomCentral is not currently one of the applications which uses this feature, as it has its own system for setting up web forms.

Link to comment
Share on other sites

Dan,

Sorry, this was a script question that was part of a bigger problem I was trying to solve. It sort of evolved in my explanation, but it is still a scripting question.

 

Marcom has iForms which is aware of what is in the FusionPro Fields (or form) when the job is submitted for preview. So they can be aware of each other, sort of. What I wanted to do was populate, via script, a field that iForms would then recognize. I can put a value in that field to render in the final output, but can't get it to pre-populate the value in the form, which is the only place iForms will detect it.

 

What I was ultimately after was a script to "Pre-populate" a field. If I can do that, then iForms will do it's part and they can talk to each other. But I don't think that is possible. It was a long shot, but worth it to me to solve a problem.

Link to comment
Share on other sites

Sorry, this was a script question that was part of a bigger problem I was trying to solve. It sort of evolved in my explanation, but it is still a scripting question.

You're right that it's a scripting question, in the sense that you're asking if there's a script that could affect something specific to MarcomCentral. But if you ask yourself, "Does this thread have any relevance to anyone who is not using the MarcomCentral application?", the answer is surely No. So this is indeed a MarcomCentral-specific question.

Marcom has iForms which is aware of what is in the FusionPro Fields (or form) when the job is submitted for preview. So they can be aware of each other, sort of.

Okay, it is true that MarcomCentral does know a bit more about the FusionPro template, by examining the template files. One thing it does is parse the Data Definition (.def) file as XML when it's uploaded with the template, finds the <DataField> tags, and gets their names and types, to have some very basic information about the data fields, so that you have a simple form to start out with even if you don't do any further form setup in MarcomCentral.

 

However, MarcomCentral doesn't have any capability to run the JavaScript rules in the template. That happens only at composition time, inside of FusionPro.

 

I suppose an enhancement that comes to mind would be a way to enter a default value for each field in the Fields dialog (FusionPro -> Data Definition -> Input Options -> Edit Fields), and put that into the DEF file, so that MarcomCentral could parse it out along with the field's name and type. That would be kind of a minimal version of what you can do in the Define HTML Form dialog.

 

I can tell you that we are working on some ways to enable more access to FusionPro templates from MarcomCentral, and to set up FusionPro jobs in a more MarcomCentral-friendly way, and while these may not quite be what you have in mind (nor my imagined enhancement above), they have a potential to be much more powerful. I can't really get into any details about that, but I'll say this by way of a hint: If you've used MarcomCentral with FusionPro for any length of time, you may have figured out that there's a pretty fundamental disconnect between the VDP-centric workflow of FusionPro, where the first step/question is "Provide a multi-record data file," and the versioned- or "one-off"-centric workflow of a typical MarcomCentral template, where the first step should be, "Tell me about your data fields." We're looking at ways to, among other things, close that gap, while still supporting VDP workflows in FusionPro.

What I wanted to do was populate, via script, a field that iForms would then recognize. I can put a value in that field to render in the final output, but can't get it to pre-populate the value in the form, which is the only place iForms will detect it.

Yes, I understand what you are trying to do. It's just not possible. Again, MarcomCentral has no capability to directly evaluate the JavaScript rules in your template.

What I was ultimately after was a script to "Pre-populate" a field. If I can do that, then iForms will do it's part and they can talk to each other. But I don't think that is possible. It was a long shot, but worth it to me to solve a problem.

It's a fine question to ask (despite being in the wrong sub-forum). If nothing else, it gives us some ideas.

Edited by Dan Korn
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...