Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vikrantyadav11/f91c8395d2d36107b2a59bc84a7731a4 to your computer and use it in GitHub Desktop.
Save vikrantyadav11/f91c8395d2d36107b2a59bc84a7731a4 to your computer and use it in GitHub Desktop.
Set Default for Single Line text field based on dropdown field selection
const customerFacingVarbatimField = getFieldById("customfield_27449");
const customerFacingVarbatimFieldValue = customerFacingVarbatimField.getValue()?.value;
const responseField = getFieldById("customfield_20579");
const responses = {
"Fix Released": "The issue has been fixed in [Version X.Y.Z] released on [Date]. Please upgrade to apply the fix.",
"Fix in Progress": "Actively working on a fix, expected in our upcoming patch [on Date].",
"Under Investigation": "The issue/request is under investigation. Updates will follow.",
"Workaround Provided": "[Share workaround].",
"Added to Backlog": "Logged for future consideration. We'll keep you posted.",
"Known Limitation": "Known product limitation. Under review for a future release.",
"Already Supported": "This feature exists. Access it via: [Instructions or link].",
"Answer Provided": "Requested info: [Add details].",
"More Information Needed": "Please clarify or provide more details on [specific part].",
"Reject": "We regret to inform you that this request has been rejected. [Add reason if needed]."
};
if (customerFacingVarbatimFieldValue === "Other") {
responseField.setReadOnly(false);
responseField.setValue(""); // Optional: clear the field so the user can enter freely
} else if (responses.hasOwnProperty(customerFacingVarbatimFieldValue)) {
responseField.setReadOnly(true);
responseField.setValue(responses[customerFacingVarbatimFieldValue]);
} else {
// Optional: default behavior for unknown values
responseField.setReadOnly(false);
responseField.setValue("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment