How to add a date field on the popup form in HR Agent Workspace.

Gurupreet Kaur
Tera Contributor

I am trying to add a Date field on a popup form in the HR Agent Workspace . However I am able to achieve this functionality using UI Page in the classic view but on Agent Workspace.

GurupreetKaur_0-1682499803784.png

 

 

Requirement - When someone tries to change the state of Hr case to pending/suspended a popup form should appear asking for reason and a due date in HR Agent Workspace. 

 

Problem - I am using a client script to display the popup form using g_modal but when i mention the type of due date field as date/datetime/Date the field disappears from the form but when it is marked as String we can see the field on the form .I think that g_modal does not supports date field type.

 

Below is the client Script -

 

var answer = response.responseXML.documentElement.getAttribute("answer");
			var reasons = JSON.parse(answer);

			if (!reasons)
				reasons = [];

			var fields = [{
					type: 'choice',
					name: 'reason',
					label: getMessage('Reason'),
					value: (reasons && reasons.length > 0) ? reasons[0].value : '',
					choices: reasons
				},
				{
					type: date,
					name: 'due_date',
					label: 'Due Date',
					
				}
			];

			var sysId = g_form.getUniqueValue();
			var tblName = g_form.getTableName();
// 			var gmodal = new GlideModal();
// 			gmodal.renderWithContent("<div>Hii There</div>");
// 			gmodal.render();

			g_modal.showFields({
				title: getMessage('Pending Reason'),
				fields: fields,
				instruction: getMessage('Provide a reason for Pending the case.'),
				size: 'md',
				confirmType: 'confirm'
			}).then(function(fieldValues) {

				//get the work note entered
				var newReason = fieldValues.updatedFields[0].value;
				var newdueDate = fieldValues.updatedFields[1].value;

				//Call the Ajax function that handles adding worknotes and state
				var s = new GlideAjax("sn_hr_core.SE_HR_Close_Dialog_Box");
				s.addParam("sysparm_name", "suspendCaseAction");
				s.addParam("sysparm_obj_id", sysId);
				s.addParam("sysparm_table_name", tblName);
				s.addParam("sysparm_due_date", newdueDate);
				s.addParam("sysparm_suspend_reason", newReason);
				s.getXML(addWorkNotes);

				function addWorkNotes(response) {
					g_form.save();
				}
            }, function() {
                // Reset state dropdown if the modal is canceled
                setState(g_scratchpad.previous_state);
			});
		});

 

  

output - 

GurupreetKaur_1-1682500583400.png

 

0 REPLIES 0