Skip to end of banner
Go to start of banner

How to fix the same pageId issue which occurs when using @pageId@

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Problem statement

This article explains how to fix the same pageId, which is used under certain circumstances using @pageId@.

Error message

When we run an action and have a file that contains copyPage as the first action and runFromPageList with modifyPage as the second action, we notice that the replacement variable @pageId@ of the second action runFromPageList is taking only the page id from the first action copyPage instead of iterating through all the pages in the space.

Commands used in the text file.

CLI action.

acli --action run --file myactions.txt

myactions.txt

myconfluence --action copyPage --id 1048612 --newSpace CON --parent 347996323 --targetServer "http://jirasso.bobfire.com:8143" --targetUser automation --targetPassword automation --replace -v
myconfluence1 --action runFromPageList --space CON  --common "--action modifyPage --id "@pageId@" --special "" # ~""   --findReplaceRegex ""(?m)<(?-s).*=""scroll-ignore""(?s).*<(?-s).*macro>#""" -v

Verbose Logs

ACLI appfireuser001$ acli --action run --file myactions.txt 

Run: myconfluence --action copyPage --id 1048612 --newSpace CON --parent 347996323 --targetServer "http://abc.com" --targetUser testuser --targetPassword **** --replace -v

URL requested: http://abc.com/rest/api/latest/content/1048612?expand=space.homepage%2Ccontainer%2Chistory%2Cversion%2Cancestors%2Cmetadata.labels%2Cbody.storage&type=page&status=current
Request type: GET
Content type: application/json; charset=utf-8
Response code: 200, message: null, url: http://abc.com/rest/api/latest/content/1048612?expand=space.homepage%2Ccontainer%2Chistory%2Cversion%2Cancestors%2Cmetadata.labels%2Cbody.storage&type=page&status=current
Successful login to: null by user: automation

Run: --action modifyPage --id "347996349" --special " # ~"   --findReplaceRegex "(?m)<(?-s).*="scroll-ignore"(?s).*<(?-s).*macro>#"
Page 'test_scroll_4' in space CON modified. Page has id 347996349.

Run: --action modifyPage --id "347996349" --special " # ~"   --findReplaceRegex "(?m)<(?-s).*="scroll-ignore"(?s).*<(?-s).*macro>#"
Content has not changed. Page is 'test_scroll_4' in space CON. Page has id 347996349

Run completed successfully. 2 actions were successful 

Run completed successfully. 2 actions were successful from file '/Users/appfireuser001/ACLI/myactions.txt'.
ACLI appfireuser001$

Solution

The @pageId@ is being substituted from the copy action BEFORE the runFromPageList runs. You need to defer the substitution until the runFromPageList runs. This is because both actions are already in a run script.

We need to move the action copyPage into a run action, as shown below and then use the runFromPageList action to modify the page. Please see the last two sample actions for reference.

#copypage
myconfluence --action runFromPageList --id 1048612 --common "--action copyPage --id @pageId@  --newSpace CON --parent 347996323 --targetServer "xxxx" --targetUser automation --targetPassword xxx --replace" -v

#Modify scroll-ignore
myconfluence1 --action runFromPageList --space CON --common "--action modifyPage --id "@pageId@" --special "" # ~""   --findReplaceRegex ""(?m)<(?-s).*=""scroll-ignore""(?s).*<(?-s).*macro>#""" -v

  • No labels