Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Auto populating combo box from another combo box - script help

Community Beginner ,
Aug 17, 2017 Aug 17, 2017

I have been trying to follow instructions on how to create combo which auto pop another combo and intern that combo box auto pop other cells.  I used an existing sample script and tried to replace there var and objects with mine but it not functioning. Can someone review my script?

I have 6 cells goals, tactics, results, budget, action, tips. Both goals and tactics are combo boxes/drop boxes and the remain four are auto pop from the tact selection.

Please note i am very new to coding and trying my very best.

******

var oTactRef = {

    "Everyday client meetings":{result:"5 referrals", budget:0, action:"Make asking for Introductions a regular part of the client meeting.", tips:"Use these meetings to initiate your new Value Discussion initiative"},

    "Phoenix Conversations": {results:"10 refferrals", budget:100, action:"Reignite your current client base by booking meetings to discuss your new brand in-depth", tips:"Let them know that their experience is valuable and that you always welcome their feedback on how you can improve"} ,

    "Client Survey Results":{results:"8 referrals", budget:150, action:"Set up reminders to regularly send clients the survey 30 to 60 days before a meeting or anniversary.", tips:"Do NOT mention to your client that you reviewed their client survey responses. They are meant to be anonymous."},

              };

var oTactDigt ={

    "Sourcing through LinkedIn":{results:"25 followers", budget:0, action:"Search for and add 10-15 clients from your list on LiknkedIn per day.",tips:"Always be prepared withw soft opening"},

    "feacebook sponsored post":{results: "30 new followers", budget:1000, action:"Run a sponsored Facebook campaign aimed at the strategic locations you have identified", tips:"Using Facebooks bidding platform for Sponsored posts, we will work with an initial budget of $500 and focus the activity around certain days, times and areas."},

    "Facebook activity":{results:"10 new followers", budget:0, action:"Every day visit www.igcontenthub.com and post 1 piece of content to your team page.", tips:"When choosing content to post, make sure to be as relevant to the day as possible."},

  };

var oGoals = {

              //"Increase New Assets":{Tactics:oTactAss},

              //"Increase Share of Wallet":{Tactics:oTactWal},

              "Increase Referrals":{Tactics:oTactRef},

              //"Increase Insurance Cases":{Tactics:oTactRef},

              //"Increase Mortgages":{Tactics:oTactMor},

              //"Increase Brand Awareness":{Tactics:oTactBrnd},

              //"Increase Volunteer-ism":{Tactics:oTactVol},

              "Increase Digital Footprint":{Tactics:oTactDigt}

              //"Increase Campaign Use":{Tactics:oTactCamp}

                     };

function SetListItems(oDataSelection, oListFld)

{

  var oListSel = oDatascource.Tactics;

  var aItemList = [" - "];

  for(var cName in oListSel)

     aItemList.push(cName);

  var prevVal = oListFld.value;

  oListFld.setItems(aItemList);

    oListFld.oDataSource = oListSel;

    oListFld.oDataSource[" - "] = {results:oDataSelection.results, budget:oDataSelection.budget, action:oDataSelection.action, tips:oDataSelection.tips,};

  oListFld.defaultValue = " - ";

  oListFld.value = bBlockValueChanges?prevVal:" - ";

}

function  SetFieldValues(cSel, oDataSource, oResultFld, oBudgetFld, oAction, oTips)

{

   if(oDataSource && cSel && !bBlockValueChanges)

   {

      var oItemVals = oDataSource[cSel];

      oResults.value = oItemVals?oItemVals.results:"";

      oBudget.value = oItemVals?oItemVals.budget:"";

      oAction.value = oItemVals?oItemVals.action:"";

      oTips.value = oItemVals?oItemVals.tips:"";

   }

}

var bBlockValueChanges = (this.getField("Goal_1").value != "");

SetListItems({price:"", budget:"", Tactics: oGoals},this.getField("goal_1"));

var bBlockValueChanges = (this.getField("Goal_2").value != "");

SetListItems({price:"", budget:"", Tactics: oGoals},this.getField("goal_2"));

var bBlockValueChanges = (this.getField("Goal_3").value != "");

SetListItems({price:"", budget:"", Tactics: oGoals},this.getField("goal_3"));

bBlockValueChanges = false;

TOPICS
Acrobat SDK and JavaScript
511
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 17, 2017 Aug 17, 2017

Hello Jennifer,

   Setting the items on multiple linked lists is complicated.  It's even more complicated because each selection has the ability to set multiple text fields as well as forcing the items to change in the next list. The method I've outlined is generic, which makes it even more complicated because it has to take into account any number of consecutive linked list.

It looks like you've taken the best approach, which is make sure the code for just setting the list items is working. The code you've posted is a document script, the location where all the important bits are defined. It is only the first part of a complicated process.

So the first issue is that is a problem is the first line in the "SetListItems()" function. It should be this:

  var oListSel = oDataSelection.Tactics;

"oDataSelection" is the value passed into the function, "oDatascource" is undefined in the context of the function.

The second bit is that "bBlockValueChanges" is being re-declared, i.e. there are multiple instances with the "var" declaration.  Only declare it once with "var".

Now your code will work.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 17, 2017 Aug 17, 2017

Now for the "SetFieldValues" function.

Notice that the arguments declared in the function signature do not match the arguments used in the body of the function, as highligned below. These need to match verbatim.

function  SetFieldValues(cSel, oDataSource, oResultFld, oBudgetFld, oAction, oTips)

{

   if(oDataSource && cSel && !bBlockValueChanges)

   {

      var oItemVals = oDataSource[cSel];

      oResults.value = oItemVals?oItemVals.results:"";

     oBudget.value = oItemVals?oItemVals.budget:"";

      oAction.value = oItemVals?oItemVals.action:"";

      oTips.value = oItemVals?oItemVals.tips:"";

   }

}

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 17, 2017 Aug 17, 2017
LATEST

As always thank you for your time Thom

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines