Sten28 Outstanding Contributor.
Outstanding Contributor.
65 views

SDK Getting UDFs via Powershell

Jump to solution

Looking for tips, tricks (or straight-up code) that might help.

I'm writing some Record properties from records via a searched search, using Powershell + the SDK (9.3x)

All record values are writing out fine, apart from User Defined Fields.

I understand via the documentation that UDFs must be called differently (using GetUserField and Field Definition) however the code examples are for VB/C - so not sure on the Powershell equivalent.

The code below works, apart from writing out the last value ($rec.UserDefinedField) which is the currently expected fail behaviour.

ForEach ($uri in $savedSearchResults.GetResultAsUriArray())
{
$rec = New-Object -TypeName HP.HPTRIM.SDK.Record -ArgumentList $database, $uri

Add-Content $filename ($rec.Uri.ToString() + "," + $rec.Owner + "," + $rec.DateRegistered + "," + $rec.DateDue + "," + $rec.DateClosed.ToShortDateString() + "," + $rec.UserDefinedField)
}

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

Re: SDK Getting UDFs via Powershell

Jump to solution

Before the loop:

$field = New-Object -TypeName HP.HPTRIM.SDK.FieldDefinition -ArgumentList $database, "FIELD_NAME"

 

inside the loop:

 

$rec.GetFieldValueAsString($field, [HP.HPTRIM.SDK.StringDisplayType]::Default, $False)

 

Or something like this, I have not tested, time for dinner.


Blog | Samples | HPE CM 9.3 SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
2 Replies
Micro Focus Expert
Micro Focus Expert

Re: SDK Getting UDFs via Powershell

Jump to solution

Before the loop:

$field = New-Object -TypeName HP.HPTRIM.SDK.FieldDefinition -ArgumentList $database, "FIELD_NAME"

 

inside the loop:

 

$rec.GetFieldValueAsString($field, [HP.HPTRIM.SDK.StringDisplayType]::Default, $False)

 

Or something like this, I have not tested, time for dinner.


Blog | Samples | HPE CM 9.3 SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
Sten28 Outstanding Contributor.
Outstanding Contributor.

Re: SDK Getting UDFs via Powershell

Jump to solution

Winner winner (chicken dinner?)

Thanks David - very much appreciated

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.