cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Hide Primary Content field in WTDocument subtype

Sha11
12-Amethyst

Hide Primary Content field in WTDocument subtype

Hello All,

 

I have a requirement where I have to hide the field Primary Content in the create and edit layout of WTDocument. I understand that it is not a part of PDM functionality but I would like to customize this and keep the primary content hidden in the form. Requesting you to shed some light on the options.

 

Thanks,

Sha

1 ACCEPTED SOLUTION

Accepted Solutions
Sha11
12-Amethyst
(To:Sha11)

The below customization done in documentManagement.js took care of this requirement.

 

function updatePrimaryContent(value){

if(value == 'wt.doc.WTDocument|typeName of the Document'){
document.getElementById("primary0contentSourceList").selectedIndex = 0;
document.getElementById("templatePickerDiv").style.display = "none";
}
//This if will hide primary content selection block
if(value == 'wt.doc.WTDocument|typeName of the Document'){
var primaryContentContainer = null;
}
else{
var primaryContentContainer = document.getElementById('primaryContentPullDown');
}

//var primaryContentContainer = document.getElementById('primaryContentPullDown');
var keepCheckoutDiv = document.getElementById('checkboxkeepCheckedOutDiv');
var attrPanelDiv = document.getElementById('setAttributesTablePane');
var horizontalLine = document.getElementById('primaryContentHzLine');
var insertLocationPickerDiv = document.getElementById('insertLocationPickerDiv');

if(value!=''){
if (primaryContentContainer != null){
primaryContentContainer.style.visibility = 'visible';
}
if (keepCheckoutDiv != null){
keepCheckoutDiv.style.visibility = 'visible';
}
if (attrPanelDiv != ''){
attrPanelDiv.style.visibility = 'visible';
}
if (horizontalLine != ''){
horizontalLine.style.visibility = 'visible';
}
if (insertLocationPickerDiv != null) {
insertLocationPickerDiv.style.visibility = 'visible';
}
}else{
if (primaryContentContainer != null){
primaryContentContainer.style.visibility = 'hidden';
}
if (keepCheckoutDiv != null){
keepCheckoutDiv.style.visibility = 'hidden';
}
if (attrPanelDiv != ''){
attrPanelDiv.style.visibility = 'hidden';
}
if (horizontalLine != ''){
horizontalLine.style.visibility = 'hidden';
}
}

}

 

function displayPrimaryContent(){
//This block will hide file selection and file description in primary Content

var type = document.getElementById('createType').value;
if(type == 'wt.doc.WTDocument|documentType Name'){
hideElement('primaryFileWidgets');
hideElement('primaryURLWidgets');
hideElement('primaryExternalWidgets');
hideElement('primarySCMWidgets');

}

else{
var source;
var sourceList = document.getElementById('primary0contentSourceList');
var scmField = document.getElementById('scmHiddenField');
if( scmField != null && typeof scmField != 'undefined' )
manageSCMConent(sourceList);
if (sourceList!=null && typeof sourceList!= 'undefined' ){

source=sourceList.value;
}else{
return;
}

// then show whatever's appropriate
// ***MEC get strings from Java constants
if ( source=="URL" ) {
showElement('primaryURLWidgets');
} else if ( source=="EXTERNAL" ) {
showElement('primaryExternalWidgets');
} else if ( source=="CLEARCASE" ) {
showElement('primarySCMWidgets');
} else if ( source=="FILE" ) {
showElement('primaryFileWidgets');
}
}
}

View solution in original post

11 REPLIES 11
Joe_Sun
20-Turquoise
(To:Sha11)

Hello Sha,

 

          Yes, it is not a part of the Windchill functionality and is not officially supported.

However, one file you probably want to do some experiment:  netmarkets/javascript/documentManagement.js

Sha11
12-Amethyst
(To:Joe_Sun)

Been experimenting with the same file for the past 2 days, no luck so far.

HelesicPetr
21-Topaz II
(To:Sha11)

Hi @Sha11 

@Joe_Sun give you good hint. 

You need to get selected type of WTDocument and basend on it show or hide the primary content panel

netmarkets/javascript/documentManagement.js

if (primaryContentContainer != null){
primaryContentContainer.style.visibility = 'visible';
}

change the visible to hidden

if (primaryContentContainer != null){
primaryContentContainer.style.visibility = 'hidden';
}

example with type control
		if (value=="YOURDOCTYPE")
		{
        if (primaryContentContainer != null){
            primaryContentContainer.style.visibility = 'hidden';
        }
		}else{
			if (primaryContentContainer != null){
            primaryContentContainer.style.visibility = 'visible';
        }

 

Then you need to preselect no content to achieve that wizard does not force you to select upload content. 

 

PetrH 

Sha11
12-Amethyst
(To:HelesicPetr)

@HelesicPetr ,

 

I believe you are talking about updatePrimaryContent() method in documentManagement.js, I did try updating that method and it did not hide the Primary Content field as expected. I introduced an if condition to that method to validate type value, but it not seem to take effect after selecting the document type in the Type dropdown.

HelesicPetr
21-Topaz II
(To:Sha11)

Hi @Sha11 

Do you use correct type value string? Do you have real value from  variable? do you compare correct value?

For example Minutes string ´= wt.doc.WTDocument|cz.aveng.in.skol.Minutes

HelesicPetr_0-1676272498962.png

 

It has to work. 

 

PetrH

Sha11
12-Amethyst
(To:HelesicPetr)

Hello @HelesicPetr ,

 

Thank you for the input, and yes, I used the correct type name only, the issue that I am facing is, after implementing those changes, the Primary Content field is getting hidden but the create WTDocument form still expects some value for Primary Content and is not allowing me to create an object. I am now looking for a way to default the Primary Content selection to No Content and then hide the field.

HelesicPetr
21-Topaz II
(To:Sha11)

Yes this is an another issue as a consequence that needs to be solved 😄

PetrH

It could be, that the preference is set, that a primary file is necessary and not optional.

Screenshot 2023-02-18 at 09.16.55.png

Sha11
12-Amethyst
(To:Sha11)

The below customization done in documentManagement.js took care of this requirement.

 

function updatePrimaryContent(value){

if(value == 'wt.doc.WTDocument|typeName of the Document'){
document.getElementById("primary0contentSourceList").selectedIndex = 0;
document.getElementById("templatePickerDiv").style.display = "none";
}
//This if will hide primary content selection block
if(value == 'wt.doc.WTDocument|typeName of the Document'){
var primaryContentContainer = null;
}
else{
var primaryContentContainer = document.getElementById('primaryContentPullDown');
}

//var primaryContentContainer = document.getElementById('primaryContentPullDown');
var keepCheckoutDiv = document.getElementById('checkboxkeepCheckedOutDiv');
var attrPanelDiv = document.getElementById('setAttributesTablePane');
var horizontalLine = document.getElementById('primaryContentHzLine');
var insertLocationPickerDiv = document.getElementById('insertLocationPickerDiv');

if(value!=''){
if (primaryContentContainer != null){
primaryContentContainer.style.visibility = 'visible';
}
if (keepCheckoutDiv != null){
keepCheckoutDiv.style.visibility = 'visible';
}
if (attrPanelDiv != ''){
attrPanelDiv.style.visibility = 'visible';
}
if (horizontalLine != ''){
horizontalLine.style.visibility = 'visible';
}
if (insertLocationPickerDiv != null) {
insertLocationPickerDiv.style.visibility = 'visible';
}
}else{
if (primaryContentContainer != null){
primaryContentContainer.style.visibility = 'hidden';
}
if (keepCheckoutDiv != null){
keepCheckoutDiv.style.visibility = 'hidden';
}
if (attrPanelDiv != ''){
attrPanelDiv.style.visibility = 'hidden';
}
if (horizontalLine != ''){
horizontalLine.style.visibility = 'hidden';
}
}

}

 

function displayPrimaryContent(){
//This block will hide file selection and file description in primary Content

var type = document.getElementById('createType').value;
if(type == 'wt.doc.WTDocument|documentType Name'){
hideElement('primaryFileWidgets');
hideElement('primaryURLWidgets');
hideElement('primaryExternalWidgets');
hideElement('primarySCMWidgets');

}

else{
var source;
var sourceList = document.getElementById('primary0contentSourceList');
var scmField = document.getElementById('scmHiddenField');
if( scmField != null && typeof scmField != 'undefined' )
manageSCMConent(sourceList);
if (sourceList!=null && typeof sourceList!= 'undefined' ){

source=sourceList.value;
}else{
return;
}

// then show whatever's appropriate
// ***MEC get strings from Java constants
if ( source=="URL" ) {
showElement('primaryURLWidgets');
} else if ( source=="EXTERNAL" ) {
showElement('primaryExternalWidgets');
} else if ( source=="CLEARCASE" ) {
showElement('primarySCMWidgets');
} else if ( source=="FILE" ) {
showElement('primaryFileWidgets');
}
}
}

HelesicPetr
21-Topaz II
(To:Sha11)

This looks better 😄

function updatePrimaryContent(value){

    if(value == 'wt.doc.WTDocument|typeName of the Document'){
        document.getElementById("primary0contentSourceList").selectedIndex = 0;
        document.getElementById("templatePickerDiv").style.display = "none";
    }
//This if will hide primary content selection block
    if(value == 'wt.doc.WTDocument|typeName of the Document'){
        var primaryContentContainer = null;
    }
    else{
        var primaryContentContainer = document.getElementById('primaryContentPullDown');
    }

//var primaryContentContainer = document.getElementById('primaryContentPullDown');
    var keepCheckoutDiv = document.getElementById('checkboxkeepCheckedOutDiv');
    var attrPanelDiv = document.getElementById('setAttributesTablePane');
    var horizontalLine = document.getElementById('primaryContentHzLine');
    var insertLocationPickerDiv = document.getElementById('insertLocationPickerDiv');

    if(value!=''){
        if (primaryContentContainer != null){
            primaryContentContainer.style.visibility = 'visible';
        }
        if (keepCheckoutDiv != null){
            keepCheckoutDiv.style.visibility = 'visible';
        }
        if (attrPanelDiv != ''){
            attrPanelDiv.style.visibility = 'visible';
        }
        if (horizontalLine != ''){
            horizontalLine.style.visibility = 'visible';
        }
        if (insertLocationPickerDiv != null) {
            insertLocationPickerDiv.style.visibility = 'visible';
        }
    }else{
        if (primaryContentContainer != null){
            primaryContentContainer.style.visibility = 'hidden';
        }
        if (keepCheckoutDiv != null){
            keepCheckoutDiv.style.visibility = 'hidden';
        }
        if (attrPanelDiv != ''){
            attrPanelDiv.style.visibility = 'hidden';
        }
        if (horizontalLine != ''){
            horizontalLine.style.visibility = 'hidden';
        }
    }

}



function displayPrimaryContent(){
//This block will hide file selection and file description in primary Content

    var type = document.getElementById('createType').value;
    if(type == 'wt.doc.WTDocument|documentType Name'){
        hideElement('primaryFileWidgets');
        hideElement('primaryURLWidgets');
        hideElement('primaryExternalWidgets');
        hideElement('primarySCMWidgets');

    }

    else{
        var source;
        var sourceList = document.getElementById('primary0contentSourceList');
        var scmField = document.getElementById('scmHiddenField');
        if( scmField != null && typeof scmField != 'undefined' )
            manageSCMConent(sourceList);
        if (sourceList!=null && typeof sourceList!= 'undefined' ){

            source=sourceList.value;
        }else{
            return;
        }

// then show whatever's appropriate
// ***MEC get strings from Java constants
        if ( source=="URL" ) {
            showElement('primaryURLWidgets');
        } else if ( source=="EXTERNAL" ) {
            showElement('primaryExternalWidgets');
        } else if ( source=="CLEARCASE" ) {
            showElement('primarySCMWidgets');
        } else if ( source=="FILE" ) {
            showElement('primaryFileWidgets');
        }
    }
}

I tried the same approach in my system. But i dont see any changes reflected. Can anyone guide through

Top Tags