Hello,
I am trying to automate the project creation, and creating a number associated to every project. This script is being used in the Project under Custom Properties. Currently I have this code setup to format it in the way required. However when running it, I get a conversion error:
Conversion error : key:PRJDetails.Number,value:003,encrypted:false - class java.lang.String Not a properties
Script presenting the error:
function Handler($context, $inputs)
{
# Customizing the project number to have 3 digits
Write-Host "Formating project number"
$prjnum = $inputs.projectnumber
$custnum = $prjnum | % padleft 3 '0'
Write-Host "Project Number is $prjnum"
Write-Host "Formated Number is $custnum"
# Formating number for the customproperties variable
Write-Host "Now Formating for Project Variable"
$customProperties =
"key:PRJDetails.Number,value:$custnum,encrypted:false"
Write-host "Formated Variable is : $customProperties"
function ToArray
{
begin
{
$output =@();
}
process
{
$output += $_;
}
end
{
return ,$output;
}
}
$array = $customProperties | ToArray
Write-host "Converted to Array : $array"
$output=@{customProperties = $array}
return $output
}
You might need to format the custom properties as an array of strings.
function Handler($context, $inputs)
{
# Customizing the project number to have 3 digits
Write-Host "Formatting project number"
$prjnum = $inputs.projectnumber
$custnum = $prjnum.PadLeft(3, '0')
Write-Host "Project Number is $prjnum"
Write-Host "Formatted Number is $custnum"
# Formating number for the customproperties variable
Write-Host "Now Formatting for Project Variable"
$customProperties = @(
"key=PRJDetails.Number,value=$custnum,encrypted=false"
)
Write-Host "Formatted Variable is : $customProperties"
$output = @{
customProperties = $customProperties
}
return $output
}
Thanks for that, it still gives the same error unfortunately.