Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Custom Property Values to a Custom Property? #178

Open
LenHoover opened this issue Mar 8, 2022 · 4 comments
Open

Adding Custom Property Values to a Custom Property? #178

LenHoover opened this issue Mar 8, 2022 · 4 comments

Comments

@LenHoover
Copy link

Hi,

How do i go about adding custom property values to a custom property?

Sceanario :

Custom Property is called Len_Test which is of Resource Type = Streams. This custom property has an existing custom property value called "123". How do i add another custom property value "456" programmatically ?

I've tried using the Update-QlikCustomProperty function however i get the following error : The remote server returned an error: (400) Bad Request.

$allcurrentvalues = $(Get-QlikCustomProperty -id 5048e219-c48b-4f45-861a-20012cd2df34).choicevalues

$allcurrentvalues += "456"

Update-QlikCustomProperty -id 5048e219-c48b-4f45-861a-20012cd2df34 -choiceValues $allcurrentvalues

Thanks

@ahaydon
Copy link
Owner

ahaydon commented Mar 8, 2022

The reason your update is failing is that the choiceValues only has one value and so when you use += it is concatenating the two strings. You need to ensure the values are in an array before adding to it. Try the following instead:

$allcurrentvalues = @((Get-QlikCustomProperty -id 5048e219-c48b-4f45-861a-20012cd2df34).choicevalues)

$allcurrentvalues += "456"

Update-QlikCustomProperty -id 5048e219-c48b-4f45-861a-20012cd2df34 -choiceValues $allcurrentvalues

I am working on refactoring the handling of properties and tags, so this should get easier with the next release as it will be possible to do this in a single command.

@LenHoover
Copy link
Author

LenHoover commented Mar 8, 2022

Hi,

Thanks, i've tested your recommendation. it still fails for the same error : The remote server returned an error: (400) Bad Request.
This is what the output of the $json variable looks like from the Update-QlikCustomProperty function before the
return Invoke-QlikPut "/qrs/custompropertydefinition/$id" $json

{"id":"5048e219-c48b-4f45-861a-20012cd2df34","createdDate":"2022/03/04 13:56","modifiedDate":"2022/03/08 22:08","modifiedByUserName":"xxxxx\xxxxxx","name":"LenTest","valueType":"Text","choiceValues":["123","456"],"objectTypes":["Stream"],"description"
:"","privileges":null,"schemaPath":"CustomPropertyDefinition"}

@ahaydon
Copy link
Owner

ahaydon commented Mar 9, 2022

There seems to be an issue with the date format in the JSON request, this could be the case if you are calling Invoke-QlikPut directly rather than it being called by Update-QlikCustomProperty. The update command calls Get-QlikCustomProperty $id -raw to ensure it has a properly formatted object before setting the properties.

Please try adding the -Verbose flag to the update command and paste the output here.

@LenHoover
Copy link
Author

LenHoover commented Mar 9, 2022

I'm using the function from your repository as is. The $prop = Get-QlikCustomProperty $id -raw is there within the Update-QlikCustomProperty function.

After me testing with the -verbose option, i noticed that it was successful however it was only successful for the 1st time, when i tested it again (change the values to something different - instead of 456 i tried 789) i received the same error (400) bad request.

Here is the output when using the -verbose option :

VERBOSE: Raw output: True
VERBOSE: Adding header x-Qlik-Xrfkey: ljtysbygsvhuncxg
VERBOSE: Calling Get for https://xxxxx.com:4242/qrs/custompropertydefinition/5048e219-c48b-4f45-861a-20012cd2df34?xrfkey=ljtysbygsvhuncxg
VERBOSE: GET https://xxxxx.com:4242/qrs/custompropertydefinition/5048e219-c48b-4f45-861a-20012cd2df34?xrfkey=ljtysbygsvhuncxg with 0-byte payload
VERBOSE: received -1-byte response of content type application/json; charset=utf-8
VERBOSE: Raw output:
VERBOSE: Adding header x-Qlik-Xrfkey: ntxohvgtczfsssle
VERBOSE: {"id":"5048e219-c48b-4f45-861a-20012cd2df34","createdDate":"2022-03-04T11:56:06.145Z","modifiedDate":"2022-03-09T17:43:20.812Z","modifiedByUserName":"SBICZA01\sa2336012","name":"LenTest","valueType":"Text","choiceValues":["123","456"],"objectTypes"
:["Stream"],"description":"","privileges":null,"schemaPath":"CustomPropertyDefinition"}
VERBOSE: Calling Put for https://xxxxx.com:4242/qrs/custompropertydefinition/5048e219-c48b-4f45-861a-20012cd2df34?xrfkey=ntxohvgtczfsssle
VERBOSE: PUT https://xxxxx.com:4242/qrs/custompropertydefinition/5048e219-c48b-4f45-861a-20012cd2df34?xrfkey=ntxohvgtczfsssle with -1-byte payload
VERBOSE: received -1-byte response of content type application/json; charset=utf-8
VERBOSE: Formatting response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants