Ticket – Auto-set Description Based on Custom Category (During Selection)

Hi Team,

I’m trying to auto-set the Description field on the Ticket form based on the selected value of a custom Category field.

:white_check_mark: I’m able to set the Description after the ticket is submitted.

:x: But I want to set the Description immediately when the Category is changed (onchange), before submission.

Also, I’ve noticed that the Short Description field (which is of type Small Text) is not working as expected on the ticket view.

Please refer to the image below for reference:

Any suggestions on how to achieve this using Custom Script or any other clean workaround?

Thanks in advance!

Hello everyone,
I got it and it’s working. i used dom in HD Form Script to set description look script >
function setupForm({
doc,
updateField,
call,
router,
$dialog,
createToast,
applyFilters,
}) {
function setDescriptionText(value) {
const el = document.querySelector(‘[contenteditable=“true”]’);

	  if (!el) {
	    console.log("could not find description field");
	    return;
	  }

	  el.innerHTML = value;

	  // Dispatch events to let Vue know about the change
	  el.dispatchEvent(new Event("input", { bubbles: true }));
	  el.dispatchEvent(new Event("blur"));
} 
return {
	onChange: {
		custom_sub_category: async (newVal) => {
			if (!newVal || !doc.custom_category) return;

			      try {
				const description = await call(
				  "<your_app_path>.get_sub_category_description",
				  {
				    custom_category: doc.custom_category,
				    custom_sub_category: newVal,
				  }
				);
			    
				if (description) {
				  setTimeout(() => {
				    setDescriptionText(description);
				  }, 300);
				}
			      } catch (err) {
				console.error("Failed to fetch description for sub-category", err);
				createToast({
				  message: "Could not load sub-category description.",
				  variant: "destructive",
				});
			      }
		    },
	},
};

}