Autocomplete with ishremote

Hi Everybody

How can I autocomplete a publication from ishremote?

Thanks!

Milly

Parents
  • Dear Milly,

    Although there is no separate commandlet available in ISHRemote to autocomplete a baseline, there is a way to achieve this.

    When you create a session using ISHRemote, the created session object can be used as gateway towards the API layer of SDL Tridion Docs.

    So assuming that you create your session object as follows:

    $mySession = New-IshSession -wsBaseUrl https://your.sdltridiondocs.url/ISHWS -PSCredential Get-Credential

    you can access the Baseline25 API functions as follows:

    $mySession.Baseline25.

    From this reference you can trigger the required API method to autocomplete your baseline. So you can use the AutocompleteBaselineByMode method and supply this with the values applicable for your request.

    The API methods are documented in the SDL Documentation portal: https://docs.sdl.com/796504/67982/sdl-tridion-docs-14-sp2/

    Kind Regards,


    Raf

Reply
  • Dear Milly,

    Although there is no separate commandlet available in ISHRemote to autocomplete a baseline, there is a way to achieve this.

    When you create a session using ISHRemote, the created session object can be used as gateway towards the API layer of SDL Tridion Docs.

    So assuming that you create your session object as follows:

    $mySession = New-IshSession -wsBaseUrl https://your.sdltridiondocs.url/ISHWS -PSCredential Get-Credential

    you can access the Baseline25 API functions as follows:

    $mySession.Baseline25.

    From this reference you can trigger the required API method to autocomplete your baseline. So you can use the AutocompleteBaselineByMode method and supply this with the values applicable for your request.

    The API methods are documented in the SDL Documentation portal: https://docs.sdl.com/796504/67982/sdl-tridion-docs-14-sp2/

    Kind Regards,


    Raf

Children
  • Thanks Raf for your prompt answer.

    I was not able to find  AutocompleteBaselineByMode in the documentation for Baseline2.5, but I found CompleteBaselineByCandidateAndMode. I assumed you meant the latter.

    However, I am having a hard time finding the right way to call the method. Here is a snippet of how I am getting the required parameters and then the error message. Could you guide me to the best way to call the method?

    Milly

    ##############################

    # Get the publication in $mypub

    $mypub = Get-IshPublicationOutput -LogicalId $pubID -RequestedMetadata $requestedmeta |
                        Sort-Object -Descending -Property version_version_value |
                        Select-Object -First 1

    # Set arguments for CompleteBaselineByCandidateAndMode
    $pasLanguages = new-object System.Collections.ArrayList($null)
    $pasLanguages.Add("en-US")
    $pasResolutions = new-object System.Collections.ArrayList($null)
    $pasResolutions.Add("VRESLOW")
    # Call method
    $ishSession.Baseline25.CompleteBaselineByCandidateAndMode(
             $mypub.fishbaseline_version_element,
             $mypub.fishmasterref_version_value ,
             "ISHLatestAvailable",
             [System.Collections.ArrayList]@(), # pasStartLogicalIds
             [System.Collections.ArrayList]@(), # pasStartResourceLogicalIds,
             $pasLanguages,
             [System.Collections.ArrayList]@(), # pasIllustrationLanguages,
             [System.Collections.ArrayList]@(), # pasResourceLanguages,
             $pasResolutions)

    ##############################

    Exception calling "CompleteBaselineByCandidateAndMode" with "9" argument(s): "[-102001] The Baseline
    GUID-E05066FF-A538-466D-ADA5-63D114B70959 does not exist. [ce:"GUID-E05066FF-A538-466D-ADA5-63D114B70959"]
    [102001;InvalidObject]"
    At C:\BCD\EFG\Scripts\attempt_autocomplete00.ps1:34 char:1
    + $ishSession.Baseline25.CompleteBaselineByCandidateAndMode(
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : FaultException`1

  • Hi Milly,

    Did you ever get this working? If yes, can you share the working snippet?

  • Hi Milly,

    Sorry for the delay. Still with respect to the error above I think you supply not the correct set of arguments to the call.

    The CompleteBaselineByCandidateAndMode expect first the baseline ID of the baseline that should be autocompleted.
    The second argument could be the baseline by which you want to autocomplete. You supply in this argument the masterref value which is the GUID of the root DITAMAP and not a baseline reference. So that is why you see the error.

    Please either keep the argument empty (as you do not want to autocomplete by an existing baselineline) or supply the correct value of the baseline which you want to use as guideline in the autocomplete routine.

    The masterref value should be included in the StartLogicalIds list.

    The fishresources value should be included in the StartResourceLogicalIds list (if you have resources attached to the publication version).

    Kind Regards,


    Raf

  • So I made it to the point where this is not throwing an error and returns the baseline report in powershell, but I am not getting the results I think I should be, either that or I  am misunderstanding what the outcome of calling this API should be.

    I am trying to emulate what we do currently in Publication Manager, which is: Click the Auto-complete button on the Baseline tab and select "Latest Released"

    I have the following code, where for now, I'm just setting $pubID to be GUID of the pub I want to autocomplete and publish. In my test publication, the map is v1 & released, the topic is v2 & draft. I would expect the topic to fall back to v1 & released, but it does not.

    $pubID = 'GUID-XXX-XXX-XXX-XXX'
    $requestedMetadata = (Set-IshMetadataField -Level Version -Name FISHBASELINE -ValueType Value)

    $mypub = Get-IshPublicationOutput -LogicalId $pubID -RequestedMetadata $requestedMetadata |
                        Sort-Object -Descending -Property version_version_value |
                        Select-Object -First 1
    # Set arguments for CompleteBaselineByCandidateAndMode
    $pasLanguages = new-object System.Collections.ArrayList($null)
    $pasLanguages.Add("en-US")
    $pasResolutions = new-object System.Collections.ArrayList($null)
    $pasResolutions.Add("VRESLOW")
    # Call method
    $ishSession.Baseline25.CompleteBaselineByCandidateAndMode(
             $mypub.fishbaseline_version_element,
             [System.Collections.ArrayList]@(), # $mypub.fishbaseline_version_element,
             'ISHLatestReleased',
             $baselineList, # pasStartLogicalIds
             [System.Collections.ArrayList]@(), # pasStartResourceLogicalIds,
             $pasLanguages,
             [System.Collections.ArrayList]@(), # pasIllustrationLanguages,
             [System.Collections.ArrayList]@(), # pasResourceLanguages,
             $pasResolutions)

    # Publish!
    $ishObject = Publish-IshPublicationOutput -LanguageCombination 'en-US' -LogicalId $pubID -OutputFormat "XHTML" -Version 1

  • Hi Mic-uh,

    You did not handle any of the autocompleted information on your publication version.

    So your code currently is retrieving the 'latest released versions' of the included objects, but you are not doing anything with the result.

    You need to transform the list of retrieved latest released versions into A valid Baseline Modifications XML structure containing all changes that need to be made to the baseline.

    This Baseline Modifications XML structure will state whether you want to update the selected version of a topic (object) or whether a new entry needs to be included in the baseline for a topic (object)
    You can save the actual changes using the Baseline 2.5 Update function which taks this Baseline Modifications XML Structure as input.

    Only after you have saved the baseline with the changes you want to apply the Publish commandlet will have the information available for further processing.

    So please include the step to save the necessary updates to the baseline in your code in between the CompleteBaseline and Publish calls.

    Kind Regards,

    Raf

  • Tip: As Publication Manager is doing the exact same calls over the public API; you can insert a https://www.telerik.com/fiddler to see which API calls are triggered by Publication Manager for certain menu items and Save (as Raf mentions, thanks)

  • Raf, Dave, where is the "magic wand" API call? That's the one we need. :-P

  • I think the rub with the code above is that the baseline report returned from CompleteBaselineByCandidateAndMode doesn't actually every autocomplete with the "Latest Released" since I'm fetching an already existing baseline that already contains version numbers. According to the docs for CompleteBaselineByCandidateAndMode at https://docs.sdl.com/796504/201265/sdl-tridion-docs-14-sp2/baseline-2-5--completebaselinebycandidateandmode the API will never actually get the "Latest Relased" but only what is already there in the baseline, which for us is always a mash of draft and released and previously released but not the latest topics.

    So I'm still at a bit of a loss on how to get a list of object versions that are the latest released.

  • I did install fiddler, but it didn't shed any light on what exactly is happening.