View Single Post
  #1  
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.

Code:
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