daanrud Posted July 19, 2017 Posted July 19, 2017 Is it possible to duplicate a graphic pick list? I am creating 5 graphic frames and all 5 of these will have the same drop list and graphic resources available to choose from for each frame. My issue is that there are about 70 graphic resources to choose from and adding these values one by one is a huge time eater. Any help on this would be great. Thanks! Quote
ScottHillock Posted July 19, 2017 Posted July 19, 2017 (edited) I assume this is with DSF or other solution. But you're probably looking for AddGraphicVariable. var array = ["Frame1","Frame2","Frame3","Frame4","Frame5"]; for (i=0; i < array.length; i++){ FusionPro.Composition.AddGraphicVariable(array[i], CreateResource("./img.pdf")); } I'm not familiar with DSF, but I'm assuming you can just put your logic above this snippet, then instead of returning something, return an empty string "" and replace what you would return where "./img.pdf" is. Edited July 19, 2017 by ScottHillock Quote
daanrud Posted July 31, 2017 Author Posted July 31, 2017 Thanks for your input Scott, and yes, this will be used in DSF. I'm pretty uneducated in JavaScript, that being said, how do I know what to put in the CreateResource string when the .pdf will be selected out of about 70 images in a dropdown? Quote
daanrud Posted August 1, 2017 Author Posted August 1, 2017 I got the dropdown to work, but I'm still not sure what to put in the CreateResource string. When I select one of the options from the dropdown, it doesn't populate an image. I'll keep trying different things. Any pointers would be greatly appreciated! Thanks Quote
Dan Korn Posted August 9, 2017 Posted August 9, 2017 It's hard to know what to do in the rule without seeing the job files, especially the data file. Can you post them here? Quote
daanrud Posted August 9, 2017 Author Posted August 9, 2017 Here is the attached .zip file. This was my attempt at getting this to work. I'm not exactly sure what to put in between the () after CreateResource, since it will be choosing an image from the resources I have uploaded. The dropdown is working, but it will not return a graphic...obviously. Thanks for your helpCorn_Pick_Brochure_TEST.zip Quote
Dan Korn Posted August 9, 2017 Posted August 9, 2017 Here is the attached .zip file. This was my attempt at getting this to work. I'm not exactly sure what to put in between the () after CreateResource, since it will be choosing an image from the resources I have uploaded. The dropdown is working, but it will not return a graphic...obviously. Okay, this is something. Although there's no actual data to test with, just one empty record. Since I don't have access to DSF to be able to fill out the web form that you set up with the HTML Form Definition dialog and generate a data file, I was hoping you would have provided some dummy data to plug in to use to test the template. If I preview with the basically empty data file you sent, I just get a whole lotta nothin'. Anyway, you seem to have changed what you're asking from your original question about how to duplicate the Pick Lists themselves in the HTML Form Definition dialog. (I assume you just broke down and did it all manually, although you could collect to generate the XML file, edit it, and re-import it with FusionPro -> Define HTML Form -> From XML File. I'll also note that if you were using MarcomCentral [the application] instead of DSF, you would just point each of the five data fields to the same graphic library in the Template Setup.) What you're really asking now, I think, is how to propagate the five different graphic frames from the five different data fields without writing five different rules. The short answer is that you don't need to write any JavaScript at all, because you already have set up those fields as Graphic fields, and the values to be names of Graphic resources. And you have already assigned each frame the graphic field name directly, so it should just work. And I can verify that if I actually put the names of some of your resources into the data file for those graphic fields, it does work. Now, having said that you don't actually need to write any code, you were on the right track with calling FusionPro.Composition.AddGraphicVariable in a loop, but (a) you need to it in OnRecordStart, and (b) you need to build up the names properly. You also don't need to call Resource or Create resource, as just the field value (the graphic name) will work. If you really wanted to do this in a rule, which you don't have to, I think this is what would be the right code, again, in OnRecordStart: for (var i = 1; i <= 5; i++) FusionPro.Composition.AddGraphicVariable("Base Genetics " + i, Field("Base Genetics " + i)); But I have to reiterate that you don't need any JavaScript code at all to do what you're doing. Now, having said again that you don't actually need to write any code, and at the risk of muddying the waters, there is a way to make this template without having to manually lay out five sets of graphic and text frames: Create a repeatable component (Template Page), with one text and graphic frame on it, and write code to call out the template as many times as you need, into a single text frame (which can overflow to new pages). If you need to scale this up and call out more than five graphics, that's the way to automate it. But if you only ever have up to five of them, the template you have is fine. Quote
daanrud Posted August 10, 2017 Author Posted August 10, 2017 Hey Dan, I ended up using the string of code in the OnRecordStart that you posted and it worked beautifully! Thank you so much for responding to my post. This will save me a great amount of time! Quote
Recommended Posts
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.