qlddev
August 28, 2017, 5:05am
1
Matrix Version:5.3.4
In SOAP API, there is a method getChildren
which will give me all the children of an asset. Unfortunately this will give me also all children that is part of the asset (content container etc).
I need to check whether an asset is the last in the asset lineage (ie, doesn’t have any “children”). What is the best way to do that? I know I can pass on type_code
when I call getChildren
but then I will need to make calls as many as all possible type_code
.
Thanks for your help.
mfong
(Marcus Fong)
August 28, 2017, 9:17pm
2
Have you tried setting this parameter to FALSE?
Dependant: indicates whether to return assets that are dependently linked to the specified asset ID or only non-dependant assets. The value for this parameter should be either TRUE (dependant) or FALSE (non-dependant) (or 1 or 0). The default value for this parameter is NULL.
1 Like
qlddev
August 29, 2017, 4:55am
3
Thank you for your reply @mfong . I have tried that but it still doesn’t give me what I need.
Setting Dependent = 1 gives me:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="qheps">
<SOAP-ENV:Body>
<ns1:GetChildrenResponse>
<GetChildrenResult>
<AssetID>331614</AssetID>
<TypeCode>bodycopy</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>331616</AssetID>
<TypeCode>content_type_wysiwyg</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>1680619</AssetID>
<TypeCode>bodycopy</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>331615</AssetID>
<TypeCode>bodycopy_div</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>1680621</AssetID>
<TypeCode>content_type_wysiwyg</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>1680620</AssetID>
<TypeCode>bodycopy_div</TypeCode>
</GetChildrenResult>
</ns1:GetChildrenResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
While setting Dependant = 0 gives me:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="qheps">
<SOAP-ENV:Body>
<ns1:GetChildrenResponse>
<GetChildrenResult>
<AssetID>331616</AssetID>
<TypeCode>content_type_wysiwyg</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>340026</AssetID>
<TypeCode>folder</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>1680617</AssetID>
<TypeCode>folder</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>1680618</AssetID>
<TypeCode>page_standard</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>1680620</AssetID>
<TypeCode>bodycopy_div</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>331615</AssetID>
<TypeCode>bodycopy_div</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>1680621</AssetID>
<TypeCode>content_type_wysiwyg</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>331614</AssetID>
<TypeCode>bodycopy</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>340027</AssetID>
<TypeCode>folder</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>1680619</AssetID>
<TypeCode>bodycopy</TypeCode>
</GetChildrenResult>
</ns1:GetChildrenResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
It seems that the following always returned regardless the value of Dependant:
<GetChildrenResult>
<AssetID>331616</AssetID>
<TypeCode>content_type_wysiwyg</TypeCode>
</GetChildrenResult>
Bart
(Bart Banda)
August 29, 2017, 9:32am
4
That’s weird, what happens if you also se the MaxDepth to 1 ? So, just get children that are direct children of the current asset?
You could also try using the JS API get children function perhaps?
https://matrix.squiz.net/manuals/web-services/chapters/javascript-api#getChildren
Also, any reason why you couldn’t just use a dynamic asset listing?
qlddev
August 30, 2017, 2:46am
5
Thanks @Bart . Using MaxDepth = 1
helps. I got the following:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="qheps">
<SOAP-ENV:Body>
<ns1:GetChildrenResponse>
<GetChildrenResult>
<AssetID>331614</AssetID>
<TypeCode>bodycopy</TypeCode>
</GetChildrenResult>
<GetChildrenResult>
<AssetID>340026</AssetID>
<TypeCode>folder</TypeCode>
</GetChildrenResult>
</ns1:GetChildrenResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
So I guess if I got only one children type of bodycopy then this asset basically doesn’t have ‘children’. Do you think that logic holds?