Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® VDP Creator

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 14th, 2018, 07:07 PM
mdlivels mdlivels is offline
Junior Community Member
 
Join Date: May 2011
Location: Gettysburg, PA
Posts: 17
Default Random Image

Hi-
Can anyone help me create a rule that will pull an image from a defined location at random? There could be as few as two images to choose from, could be more, but the selection should be random. This is for print, not web.

Creator 10.03, PC, Producer server

Last edited by mdlivels; August 14th, 2018 at 07:10 PM..
Reply With Quote
  #2  
Old August 15th, 2018, 12:06 PM
ScottHillock ScottHillock is offline
Regular Contributor
 
Join Date: Mar 2010
Posts: 91
Default Re: Random Image

This should do it:

Code:
var PDFNames = [
'1.pdf',
'2.pdf',
'3.pdf',
'4.pdf'
];

var RandomNum =  Math.floor(Math.random() * PDFNames.length);

return CreateResource(PDFNames[RandomNum]);
Reply With Quote
  #3  
Old August 16th, 2018, 01:29 PM
mdlivels mdlivels is offline
Junior Community Member
 
Join Date: May 2011
Location: Gettysburg, PA
Posts: 17
Default Re: Random Image

Thanks, Scott. Not working for whatever reason. When I go to process the project (just one page) it sits for hours on 0%. I'm not sure what the issue is, but it's not fond of that code! I put that into an empty Javascript rule (graphic) and put it into an image box, but nothing.
Reply With Quote
  #4  
Old August 16th, 2018, 01:39 PM
ScottHillock ScottHillock is offline
Regular Contributor
 
Join Date: Mar 2010
Posts: 91
Default Re: Random Image

When you validate the rule in the rule editor do you get an error message? Did you have the CreateResource pointing to an absolute path?
Reply With Quote
  #5  
Old August 16th, 2018, 02:18 PM
mdlivels mdlivels is offline
Junior Community Member
 
Join Date: May 2011
Location: Gettysburg, PA
Posts: 17
Default Re: Random Image

I have an update! Must be something else happening with this template (it's an existing one that I didn't create, so there are TONS of rules already). I pulled your code out to a clean new file and it works perfectly. Can't thank you enough for this - many, many thanks!
Reply With Quote
Reply

Tags
array, image, random

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:15 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.