sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

Site Design addNavLink action gives an invalid type error

Open expiscornovus opened this issue 8 years ago • 6 comments

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

When using the addnavlink actions in a site script I expect the items being created in the navigation of a site that has been created from a site design which contains that site script.

Observed Behavior

When using a addNavLink action from the Site Design json schema the navigation links who have the isWebRelative value of true aren't added to the created site. In the getting things ready pane you see the notification: One more more of the properties on this action has an invalid type

addnavlinkerror

I have tried if the same scripts works with links that have the property isWebRelative value set to false. Those links actually work. I also have tried the same site script on Team Site, that kind of site shows the same behaviour.

Steps to Reproduce

  1. Put a script with the addNavLink action in variable in PowerShell, I used the example of the Site Design document:
$script = @'
{
    "$schema": "schema.json",
        "actions": [
			{
						"verb": "addNavLink",
						"url": "/Customer Event Collateral",
						"displayName": "Event Collateral",
						"isWebRelative": true
			},
			{
						"verb": "addNavLink",
						"url": "/Lists/Project Activities",
						"displayName": "Project Activities",
						"isWebRelative": true
			}
        ],
        "bindata": { },
        "version": 1
};
'@
  1. Add the script via PnP PowerShell Add-PnPSiteScript -Title "My Site Script" -Description "A more detailed description" -Content $script
  2. Add a Communication Site Design via PnP PowerShell Add-PnPSiteDesign -Title "My Company Design" -SiteScriptIds "SomeGUID" -Description "My description" -WebTemplate CommunicationSite
  3. Create a Communication Site based a the newly created Site Design

expiscornovus avatar Mar 26 '18 11:03 expiscornovus

Hi @expiscornovus - sorry for the slow reply here. The sample syntax looks fine (though we should probably remove that trailing semi-colon; it's not necessary) - but is there anything else in your script - like the event collateral library or project activities list? I suspect it's failing because the path references are invalid if those lists don't exist.

seansquires avatar Apr 19 '18 17:04 seansquires

@seansquires thanks for your reply! :)

This was the entire site design script I used. The lists I am linking to don't exist yet. So you are right, the path references are invalid.

But, if I remember correctly in the user interface the path field isn't validated, right? When I manually add those same two links with the same values for the path field in the top navigation they are accepted and not marked as invalid.

Btw, I will try to reproduce the same scenario but I will use the createSPList actions first. That will be the workaround for me.

expiscornovus avatar Apr 24 '18 13:04 expiscornovus

@seansquires just to let you know, the workaround is working :)

I can add the navigation links after I created the lists with the createSPList action.

testnav2

$script = @'
{
    "$schema": "schema.json",
        "actions": [
			{
            "verb": "createSPList",
            "listName": "Customer Event Collateral",
            "templateType": 101,
			},
			{
            "verb": "createSPList",
            "listName": "Project Activities",
            "templateType": 101,
			},
			{
						"verb": "addNavLink",
						"url": "/Customer Event Collateral",
						"displayName": "Event Collateral",
						"isWebRelative": true
			},
			{
						"verb": "addNavLink",
						"url": "/Project Activities",
						"displayName": "Project Activities",
						"isWebRelative": true
            }
    ],
        "bindata": { },
        "version": 1
}
'@

expiscornovus avatar Apr 30 '18 08:04 expiscornovus

Thanks for replying @expiscornovus - yes, the addNavLink action can only work on valid URL paths - and in the case of site referenced objects, they must be declared first (unless they are already in the template, like the documents library - a duplicate link could be created that would work as it's created as a part of the base template). Cheers!

seansquires avatar Apr 30 '18 15:04 seansquires

@seansquires thanks for clarifying that for me. I will close the issue.

expiscornovus avatar May 01 '18 14:05 expiscornovus

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 28 '20 06:01 msft-github-bot