Time Card Adding Notes

ismad400
Tera Contributor

The Time Sheet Portal currently allows users to add notes to time cards within the time sheet. We’ve received a request to automatically transfer the note entered on a time card for a specific project or project task as a work note to the corresponding project or task record. Is this functionality possible to implement? If so, could you please provide guidance on the best way to achieve this?, thank you

2 REPLIES 2

shantanu_patel8
Mega Guru

Hi @ismad400 ,

 

The best way to achieve it would be using business rules, you can create a 'after' business rules on 'time card' table with condition as :

shantanu_patel8_0-1748234572860.png

 

In the script you can query "Project" or "Project task" on the basis of what is selected in the task field. You can update the notes to the task work notes.

 

Please mark the answer helpful clicking on 👍 and correct if it helps the issue. Happy scripting 🙂

 

-Shantanu

 

Bert_c1
Kilo Patron

@ismad400 

To finish what was started above, a script follows, Advanced must be check on the BR to use it.

 

(function executeRule(current, previous /*null when async*/) {

	// get journal field value
	var notesValue = 'Not Found';
	var jNotes = new GlideRecord('sys_journal_field');
	jNotes.addQuery('element_id', current.sys_id);
	jNotes.addQuery('name', 'time_card');
	jNotes.orderByDesc('sys_created_on');
	jNotes.query();
	if (jNotes.next()) {
		notesValue = jNotes.value;
	}
	// now find the related task
	var tsk = new GlideRecord('task');
	tsk.addQuery('sys_id', current.task);
	tsk.query();
	if (tsk.next()) {
		// Create new journal entry
//		gs.addInfoMessage("task Table: " + tsk.sys_class_name + " sys_id: " + tsk.sys_id);
		var sjn = new GlideRecord('sys_journal_field');
		sjn.initialize()
		sjn.element_id = tsk.sys_id;
		sjn.name=tsk.sys_class_name;
		sjn.value = notesValue;
		sjn.element='work_notes';
		var rslt = sjn.insert();
//		gs.addInfoMessage('update result: ' + rslt);
	}

})(current, previous);