If you need to change the data in one or more reports in WATS, you will have to re-submit those reports. You can do this in several ways.
- You can use the WATS Client API to load the reports from the server, apply changes and re-submit them:
TDM api = new TDM();
api.InitializeAPI(true);
WatsReportHeader[] reportHeaders = api.FindReports("PN eq '12345' and Rev eq 'v1.2' and ReportType eq 'UUT'", 1000);
foreach(WatsReportHeader reportHeader in reportHeaders)
{
UUTReport report = (UUTReport)api.LoadReport(reportHeader.Guid.ToString());
report.Purpose = "Test";
report.Location = "Here";
api.Submit(report);
}
NOTE: Using the WATS Client API to re-submit reports changes which client the report belongs to with regards to restricted users.
- You can use the WATS REST API to get reports, apply changes and re-submit them. Here is an example using PowerShell:
$token = "--your-token-here--"
$url = "http://wats-server.ad.internal"
$headers = @{ 'Authorization' = "Basic $token" }
$getlist = "$url/api/report/query/header?`$filter=PartNumber eq '12345' and Revision eq 'v1.2' and ReportType eq 'T'&`$top=1000"
$list = Invoke-RestMethod -Uri $getlist -Headers $headers
$list | ft -Property UUID,SerialNumber,PartNumber,Start
Foreach ($r in $list)
{
# Retreive wrml from server
$uuid = $r.UUID.ToString()
$reporturl = "$url/api/internal/report/wrml/$uuid"
$report = Invoke-WebRequest -Uri "$reporturl" -Headers $headers
$wrml = [xml]$report.Content
#$wrml.Save("c:\Virinco\WATS\orig-$uuid.xml")
# Do the modifications:
$wrml.Reports.Report.Purpose="Test"
$wrml.Reports.Report.Location="Here"
# Post back to server:
#$wrml.Save("c:\Virinco\WATS\new-$uuid.xml")
$xmlstring = $wrml.OuterXml
$postreporturl = "$url/api/report"
$result = Invoke-WebRequest -Uri "$postreporturl" -Headers $headers -Method Post -Body "$xmlstring"
$result
}
Comments
0 comments
Please sign in to leave a comment.