Skip to main content
pshashipreetham
18-Opal
June 4, 2026
Solved

Bulk update the Attributes of the Documents in Windchill

  • June 4, 2026
  • 1 reply
  • 18 views

Hi. 

 

I have a couple of Attributes in Windchill, around 3000+ documents. Where the attribute values need updating. Manually, it will take Days and weeks to update. 

 

Thanks. 

Best answer by pshashipreetham
let csvData = Resources["CSVParserFunctions"].ReadCSVFile({
path: "All.csv",
hasHeader: true,
fileRepository: "FileRepository",
dataShape: "AutoUploadCSV.DS"
});

let distinctData = me.getWrongMachineModelData();

for(let x = 0; x < distinctData.length; x++)
{
try
{
let response = Things["windchill-Odata-connector"].GetDocuments({
$filter: "Number eq '"+distinctData.rows[x].SBNumber+"'",
$select: "ID,VersionID"
});

try
{
let checkOut = Things["windchill-Odata-connector"].docuemntCheckout({
ID: response.value[0].ID
});

} catch(e){}

let response2 = Things["windchill-Odata-connector"].GetDocuments({
$filter: "Number eq '"+distinctData.rows[x].SBNumber+"'",
$select: "ID,VersionID"
});

let Model = [];

let distinctDataSBMM = Resources["InfoTableFunctions"].Query({
t: csvData,
query: {
"filters": {
"type": "EQ",
"fieldName": "SBNumber",
"value": distinctData.rows[x].SBNumber
}
}
});

distinctDataSBMM = Resources["InfoTableFunctions"].Distinct({
t: distinctDataSBMM,
columns: "SBNumber,MachineModel"
});

for(let y = 0; y < distinctDataSBMM.length; y++)
{
Model.push({
"Value": distinctDataSBMM.rows[y].MachineModel,
"Display": distinctDataSBMM.rows[y].MachineModel
});
}

let updateDocument = Things["windchill-Odata-connector"].updateDocument({
ID: response2.value[0].VersionID,
Document: {
"@odata.type": "#PTC.DocMgmt.SalesBrochure",
"Model": Model
}
});

result = updateDocument;
} catch(e){}
}


--
Thanks.

1 reply

pshashipreetham
pshashipreetham18-OpalAuthorAnswer
18-Opal
June 4, 2026
let csvData = Resources["CSVParserFunctions"].ReadCSVFile({
path: "All.csv",
hasHeader: true,
fileRepository: "FileRepository",
dataShape: "AutoUploadCSV.DS"
});

let distinctData = me.getWrongMachineModelData();

for(let x = 0; x < distinctData.length; x++)
{
try
{
let response = Things["windchill-Odata-connector"].GetDocuments({
$filter: "Number eq '"+distinctData.rows[x].SBNumber+"'",
$select: "ID,VersionID"
});

try
{
let checkOut = Things["windchill-Odata-connector"].docuemntCheckout({
ID: response.value[0].ID
});

} catch(e){}

let response2 = Things["windchill-Odata-connector"].GetDocuments({
$filter: "Number eq '"+distinctData.rows[x].SBNumber+"'",
$select: "ID,VersionID"
});

let Model = [];

let distinctDataSBMM = Resources["InfoTableFunctions"].Query({
t: csvData,
query: {
"filters": {
"type": "EQ",
"fieldName": "SBNumber",
"value": distinctData.rows[x].SBNumber
}
}
});

distinctDataSBMM = Resources["InfoTableFunctions"].Distinct({
t: distinctDataSBMM,
columns: "SBNumber,MachineModel"
});

for(let y = 0; y < distinctDataSBMM.length; y++)
{
Model.push({
"Value": distinctDataSBMM.rows[y].MachineModel,
"Display": distinctDataSBMM.rows[y].MachineModel
});
}

let updateDocument = Things["windchill-Odata-connector"].updateDocument({
ID: response2.value[0].VersionID,
Document: {
"@odata.type": "#PTC.DocMgmt.SalesBrochure",
"Model": Model
}
});

result = updateDocument;
} catch(e){}
}


--
Thanks.

Shashi Preetham || +91 8099838801