Update Journal Entry Field from Script

Robbie Lacivita
Tera Guru

I have created a client script to show or hide attachments based on if a user is in a list. This works great, I will share the code below.

However, the other requirement is for the journal entry to be update with a statement when a user is added to the list, and I am unsure how to make that happen. All attempts at this result in an infinite loop.

 

onChange Client Script:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		
		var user = g_user.userID;
		var attach = g_form.getValue('u_add_attachment').toString();
		var array = attach.split(',');
		var isTrue = false;
		
				g_form.showFieldMsg('u_add_attachment','I certify that I have reviewed my attachments and verified they do NOT contain UNNPI.','info');
		
		for (var i=0; i < array.length; i++) {
			//alert('reverence value is '+ array);
			if(array[i].includes(user.toString())){
				isTrue=true;
				break;
			}
			
		}
		
		if(isTrue==true){
			
			g_form.enableAttachments();
			
		}
		else{
			g_form.disableAttachments();
		}
		
		return;
	}
}

Thanks,

Robbie

1 REPLY 1

sachin_namjoshi
Kilo Patron
Kilo Patron

You need to use GlideAjax from your client script to update journal field.

 

REgards,

Sachin