mdlivels Posted August 15, 2018 Share Posted August 15, 2018 (edited) 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 Edited August 15, 2018 by mdlivels Quote Link to comment Share on other sites More sharing options...
ScottHillock Posted August 15, 2018 Share Posted August 15, 2018 This should do it: var PDFNames = [ '1.pdf', '2.pdf', '3.pdf', '4.pdf' ]; var RandomNum = Math.floor(Math.random() * PDFNames.length); return CreateResource(PDFNames[RandomNum]); Quote Link to comment Share on other sites More sharing options...
mdlivels Posted August 16, 2018 Author Share Posted August 16, 2018 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. Quote Link to comment Share on other sites More sharing options...
ScottHillock Posted August 16, 2018 Share Posted August 16, 2018 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? Quote Link to comment Share on other sites More sharing options...
mdlivels Posted August 16, 2018 Author Share Posted August 16, 2018 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! Quote Link to comment Share on other sites More sharing options...
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.