How to update client script to hide attachment header

Brian185
Kilo Contributor

I have a client script that hides multiple parts of a form. It's HR Case but I think my question is more universal. Right now I have a section that looks like 

	g_form.hideRelatedList('REL:b65330019f22120047a2d126c42e70f2');
	g_form.hideRelatedList('REL:f6d4f37d2f031200b3c9a310c18c95a3');
	g_form.hideRelatedList('sn_hr_core_case.parent');
	g_form.hideRelatedList('REL:765330019f22120047a2d126c42e70f2');
	g_form.setSectionDisplay('case_history', false);
	g_form.setSectionDisplay('customer_communications', false);

I'm still learning coding. I want to add the attachment area so its hidden by the same event. I know that it lives in 'header_attachment'.

How do I translate that to the g_form format I have?

1 ACCEPTED SOLUTION

Paul Curwen
Giga Sage

Not sure why you want to do this, and I'm not recommending this as best practice, but this an On Load Client script as per below will do the trick:

 

function onLoad() {

    document.getElementById('header_attachment').style.display = 'none';

    document.getElementById('header_attachment_line').style.display = 'none';

}

 

also on your client script, you need to set the Isolate script field to false (since London release). This field is not found on the form layout OOTB, you will need to add it. Once this field is unchecked, your script should work.

 

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

View solution in original post

4 REPLIES 4

Paul Curwen
Giga Sage

Not sure why you want to do this, and I'm not recommending this as best practice, but this an On Load Client script as per below will do the trick:

 

function onLoad() {

    document.getElementById('header_attachment').style.display = 'none';

    document.getElementById('header_attachment_line').style.display = 'none';

}

 

also on your client script, you need to set the Isolate script field to false (since London release). This field is not found on the form layout OOTB, you will need to add it. Once this field is unchecked, your script should work.

 

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

Sorry for the lack of context. The whole script is 

function onLoad() {
	
	//alert(g_scratchpad.groups);
	if(g_scratchpad.groups == true){
		
		//if  hide sections business rule evaluates to true then all related lists ans all sections are viewable.
		g_form.showRelatedList('REL:b65330019f22120047a2d126c42e70f2');
		g_form.showRelatedList('REL:f6d4f37d2f031200b3c9a310c18c95a3');
		g_form.showRelatedList('sn_hr_core_case.parent');
		g_form.showRelatedList('REL:765330019f22120047a2d126c42e70f2');
		g_form.setSectionDisplay('case_history', true);
		g_form.setSectionDisplay('customer_communications', true);
		
		
	}
else{
	//if hide sections business rule evaluates to false then all sections excludinf worknotes and all related lists will be hidden.
	g_form.hideRelatedList('REL:b65330019f22120047a2d126c42e70f2');
	g_form.hideRelatedList('REL:f6d4f37d2f031200b3c9a310c18c95a3');
	g_form.hideRelatedList('sn_hr_core_case.parent');
	g_form.hideRelatedList('REL:765330019f22120047a2d126c42e70f2');
	g_form.setSectionDisplay('case_history', false);
	g_form.setSectionDisplay('customer_communications', false);
}
	
	///There is an additional business rule that allows "Cases for Customer" related list to be available if it meets conditions. 
	
}


Essentially we have some rules so if you are not in the assignment group you can only see part of the case. We want to add to that so you also cannot see any attachments. 

Ok makes sense, just add the two lines in my reply to the else and you should be good to go.

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

Hi Paul, I tried this in my DEV environment and it works as expected in the platform in the sp view within the platform. I also display the sp view in the service portal however the header_attachment still shows in the service portal. Anyone know how to make it work in the Service Portal too? I have it currently set to global but it still does not hide in the portal. I have tried all 3 ui type options too

phil34_0-1706157680627.png

they are hidden in this view

phil34_1-1706157757804.png

But showing in the service portal

phil34_2-1706157877824.png

any assistance would be appreciated