Typescript function : Create a condition in action create

Hello,
In my action create in typescript, i will like to create a condition in the two or three columns.

Example:

In my action create, i would like to have :
````if First 1 = ‘C0 - No Root Cause Found’ and Second 2 = ‘C01 - No Fault Found’ then Second3 = ‘Has not been able to reproduce the default’````

First1 Second 2 Second 3
C0 - No Root Cause Found C01 - No Fault Found Has not been able to reproduce the default
C02 - No Root Cause Found Default has been reproduced but the Root Cause has not been found
C1 - MACHINERY / EQUIPMENT C11 - Maintenance Issue caused by inadequate preventive or corrective maintenance (e.g., lubrication, filters).
C12 - Tooling / Fixtures Issue caused by broken, worn, or incorrect tools, jigs, or fixtures.
C13 - Machine Failure Unanticipated hardware failure or breakdown of the equipment.
C14 - Software / CNC Issue caused by NC program errors, software bugs, or data transfer errors.
C15 - Calibration Measurement equipment used was out of calibration or expired.
C2 - MATERIAL C21 - Raw Material The raw material (metal, composite, chemical) did not meet specifications.
C22 - Supplier / Sub-tier Non-conformance originated from a sub-tier supplier or vendor product.
C23 - Shelf Life Expired time-sensitive material was used (e.g., sealants, adhesives).

Hi! @Elodie

Do you need help with the Typescript Syntax?

Or where are you blocked at the moment?

Developer Assist is for example giving me based on your instructions the following code:

import { createEditBatch, Edits } from "@osdk/functions";
import { Client } from "@osdk/client";
// Import your object type - replace 'YourObjectType' with your actual object type
import { YourObjectType } from "@ontology/sdk";

type OntologyEdit = Edits.Object<YourObjectType>;

export default function createActionWithConditions(
client: Client,
first1: string,
second2: string,
// Add other parameters as needed
): OntologyEdit[] {
const batch = createEditBatch<OntologyEdit>(client);

// Define your conditional logic
let second3Value: string = "";

// Main conditional logic based on your example
if (first1 === "C0 - No Root Cause Found" && second2 === "C01 - No Fault Found") {
second3Value = "Has not been able to reproduce the default";
}
else if (first1 === "C0 - No Root Cause Found" && second2 === "C02 - No Root Cause Found") {
second3Value = "Default has been reproduced but the Root Cause has not been found";
}
else if (first1 === "C1 - MACHINERY / EQUIPMENT") {
// Handle C1 subcategories
switch (second2) {
case "C11 - Maintenance":
second3Value = "Issue caused by inadequate preventive or corrective maintenance (e.g., lubrication, filters).";
break;
case "C12 - Tooling / Fixtures":
second3Value = "Issue caused by broken, worn, or incorrect tools, jigs, or fixtures.";
break;
case "C13 - Machine Failure":
second3Value = "Unanticipated hardware failure or breakdown of the equipment.";
break;
case "C14 - Software / CNC":
second3Value = "Issue caused by NC program errors, software bugs, or data transfer errors.";
break;
case "C15 - Calibration":
second3Value = "Measurement equipment used was out of calibration or expired.";
break;
default:
second3Value = ""; // Default case for C1 category
}
}
else if (first1 === "C2 - MATERIAL") {
// Handle C2 subcategories
switch (second2) {
case "C21 - Raw Material":
second3Value = "The raw material (metal, composite, chemical) did not meet specifications.";
break;
case "C22 - Supplier / Sub-tier":
second3Value = "Non-conformance originated from a sub-tier supplier or vendor product.";
break;
case "C23 - Shelf Life":
second3Value = "Expired time-sensitive material was used (e.g., sealants, adhesives).";
break;
default:
second3Value = ""; // Default case for C2 category
}
}
else {
// Default case for unmatched conditions
second3Value = "";
}

// Create or update the object with the calculated values
// Option 1: If creating a new object
batch.create(YourObjectType, {
// primaryKey: yourPrimaryKeyValue, // Set your primary key
first1: first1,
second2: second2,
second3: second3Value,
// Add other properties as needed
});

// Option 2: If updating an existing object
// batch.update(
// { $apiName: "YourObjectType", $primaryKey: yourPrimaryKeyValue },
// {
// first1: first1,
// second2: second2,
// second3: second3Value
// }
// );

return batch.getEdits();
}

You get to Developer Assist here in Foundry: In the left bottom: