Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library


Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old April 21st, 2022, 03:37 PM
LisaHansen LisaHansen is offline
Junior Community Member
Join Date: Sep 2008
Location: Atlanta, GA
Posts: 16
Default Issue with blank or no selection

I'm working on a project where images are returned from an external data file. The user can make up to three choices from drop-downs. In the ExDF, several drop-down options may point to the same image file. The client does not want duplicate images, so I put together the code below. If options are chosen for all three fields, it works great.

var externalDF = new ExternalDataFileEx("Competitor-ExDF.xlsx", "Excel");

var a = externalDF.FindRecord("CompetitorDropDown", Field("CP-Product-1-A"));
var b = externalDF.FindRecord("CompetitorDropDown", Field("CP-Product-1-B"));
var c = externalDF.FindRecord("CompetitorDropDown", Field("CP-Product-1-C"));

var caseA = ((externalDF.GetFieldValue(a, "CompetitorImage")));
var caseB = ((externalDF.GetFieldValue(b, "CompetitorImage")));
var caseC = ((externalDF.GetFieldValue(c, "CompetitorImage"))); 

var resultA = Resource(externalDF.GetFieldValue(a, "CompetitorImage")).content;
var resultB = Resource(externalDF.GetFieldValue(b, "CompetitorImage")).content;
var resultC = Resource(externalDF.GetFieldValue(c, "CompetitorImage")).content;

if ((caseA != caseB) && (caseA != caseC) && (caseB != caseC))  {return resultA + " " + resultB + " " + resultC;}

if ((caseA == caseB) && (caseA != caseC))  {return resultA + " " + resultC;}

if ((caseA == caseB) && (caseA == caseC))  {return resultA;}

if ((caseA != caseB) && (caseA == caseC))  {return resultA + " " + resultB;}

if ((caseA != caseB) && (caseA != caseC) && (caseB == caseC)) {return resultA + " " + resultB;}

else return "";
I'm having an issue if they don't choose something for all three. Ideally, they should be able to choose just A or A and B if they'd like. Currently, if only one or two options are chosen, it breaks the whole table. This rule is just for the first row. The images appear side-by-side if there is more than one unique image. How can I change this so if there is nothing in choices B or C it will still return A (or A & B if only C is blank)?

Thank you for looking!

Last edited by LisaHansen; April 21st, 2022 at 03:49 PM.. Reason: Added information
Reply With Quote

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 06:50 AM.

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