Skip to main content
Question

Scripting Logic for IF-Then-Else

  • February 20, 2026
  • 3 replies
  • 27 views

Forum|alt.badge.img+3

Hello all

 

Have a script that creates new records in a table and then populates select fields in these newly created records with values from previous values. Works good, but I am interested in adding a new conditional argument that will do the following:

 

IF: “Previous Assessment Status" is any value other than “First Assessment" or “Not Assessed";

THEN: “Current Assessment Status" should be the value of “Previous Assessed";

ELSE: the value of “Current Assessment Status" should be “Not Assesed"

 

Hoping someone can help with the structure of the conditional logic. Script is below:

 

let {foundRecordNames, foundRecordDate, linkedRecordID, valStartupID, prevStatus} = input.config()

//Set the table to create the records in

let table = base.getTable('TRK: 360° ASSESSMENT')

let recordsToCreate = new Array;

 

for (let i = 0; i < foundRecordNames.length; i++){

    recordsToCreate.push({

        fields:{               

            "Previous Assessment Status": {name: prevStatus[i]},

            "Current Assessment Status": {"name": "Not Assessed"},

            "Area Assessed": [{id: foundRecordNames[i]}],

            "TRK: ASSESSMENT": [{id: linkedRecordID}],

            "Startup Name": [{id: valStartupID}],

            "Assessment Date": foundRecordDate            

        }

    })

}

3 replies

Mike_AutomaticN
Forum|alt.badge.img+28

Hey ​@KenF,

I do not code, nor did I gave the following a shot, but you might want to test this out (Claude generated :D):

 

let {foundRecordNames, foundRecordDate, linkedRecordID, valStartupID, prevStatus} = input.config()

let table = base.getTable('TRK: 360° ASSESSMENT')
let recordsToCreate = new Array;

for (let i = 0; i < foundRecordNames.length; i++){
let previousStatus = prevStatus[i];
let currentStatus = (previousStatus !== "First Assessment" && previousStatus !== "Not Assessed")
? previousStatus
: "Not Assessed";

recordsToCreate.push({
fields:{
"Previous Assessment Status": {name: previousStatus},
"Current Assessment Status": {name: currentStatus},
"Area Assessed": [{id: foundRecordNames[i]}],
"TRK: ASSESSMENT": [{id: linkedRecordID}],
"Startup Name": [{id: valStartupID}],
"Assessment Date": foundRecordDate
}
})
}


 

Completely different matter, but would love to have you join the March 2026 AT Community led Hackathon! Make sure to sign up!!

 

Mike, Consultant @ Automatic Nation 
YouTube Channel


Forum|alt.badge.img+2
  • Participating Frequently
  • February 20, 2026

Straightforward conditional. Inside the loop, resolve the value before building the record object:
                                                                                         
  for (let i = 0; i < foundRecordNames.length; i++) {
                                                                                               let currentStatus = (prevStatus[i] !== "First Assessment" && prevStatus[i] !== "Not
   Assessed")
          ? prevStatus[i]
          : "Not Assessed";

      recordsToCreate.push({
          fields: {
              "Previous Assessment Status": { name: prevStatus[i] },
              "Current Assessment Status": { name: currentStatus },
              "Area Assessed": [{ id: foundRecordNames[i] }],
              "TRK: ASSESSMENT": [{ id: linkedRecordID }],
              "Startup Name": [{ id: valStartupID }],
              "Assessment Date": foundRecordDate
          }
      });
  }

  The key piece is the ternary:

  let currentStatus = (prevStatus[i] !== "First Assessment" && prevStatus[i] !== "Not    
  Assessed")
      ? prevStatus[i]    // use previous value
      : "Not Assessed";  // default

  Both conditions use !== (not equal) joined by && (and) — so it only carries forward the
   previous status when it's a "real" assessment value, not one of the two excluded      
  statuses.


Forum|alt.badge.img+3
  • Author
  • New Participant
  • February 21, 2026

Gents… Thank you both so much. ​@Mike_AutomaticN ​@NickEFSJ 

Script works perfectly... Appreciate your help!