A way to do that is using the following tag:
The tag reference for it is here:
An example of my own based on the sample provided in the tag reference is the following where I retrieve the id for a content child of type Content_C via its cid and then I look for its parent (content type Content_P):
<% String cid = ics.GetVar("cid"); %> <searchstate:create name="mainSS" op="or"/> <!-- add constraint to get parents for the specified child in cid --> <searchstate:addhasdescendantconstraint name="mainSS" assetid='<%=cid %>' assettype="Content_C" bucket="ss2" /> <!-- results of the list are parents for the assest specified in cid --> <assetset:setsearchedassets name="myassetset" constraint="mainSS" assettypes="Content_P"/> <!-- transform assetset to list to retrieve id --> <assetset:getassetlist name="myassetset" listvarname="aslist"/> <!-- loop through list and render parent id's --> <ics:listloop listname="aslist"> parent id: <ics:listget fieldname="assetid" listname="aslist"/> </ics:listloop>
Hope it helps.
As Pedro suggested, that is one way to get the Parent Id.
2nd way is to use FieldCopier on Parent asset - Copy the asset id in some custom attribute say "ParentId" and after saving any Parent asset, this ParentId will contain asset id of the parent asset which will be available to child asset using assetset:getattributevalue tag wherein you can set immediateOnly="false" to get this "ParentId" value and perform whatever operation you want to.
I hope this helps.