Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get full version history of SharePoint list item from from begining #3134

Open
deep-ponkiya-web opened this issue Sep 19, 2024 · 8 comments

Comments

@deep-ponkiya-web
Copy link

deep-ponkiya-web commented Sep 19, 2024

What version of PnPjs library you are using

3.x

Minor Version Number

1.0

Target environment

All

Additional environment details

"@pnp/sp": "^3.13.0",
"react": "17.0.1",
"@microsoft/sp-core-library": "^1.17.1",
"@microsoft/sp-lodash-subset": "^1.17.1",
"@microsoft/sp-office-ui-fabric-core": "^1.17.1",
"@microsoft/sp-property-pane": "^1.17.1",
"@microsoft/sp-webpart-base": "^1.17.1",

Question/Request

i am working with spfx with react.i need full version history of SharePoint list item from begining.
but pnp/js return version number 10.0 when history more then 50. please assist me for this issue.

export const getItemHistory = async (Id, LIST_NAME) => {
    let queryParams = new GET_LIST_QUERY_PARAMS();
    queryParams.selectProperties = ["*,Versions"];
    queryParams.expandProperties = ["Versions"];

    const assetResult = await getSPListItemById(
        LIST_NAME,
        queryParams.selectProperties,
        queryParams.expandProperties,
        Id
    );

    return assetResult;
}

@juliemturner
Copy link
Collaborator

@deep-ponkiya-web
Copy link
Author

deep-ponkiya-web commented Sep 19, 2024

Did you try this: https://pnp.github.io/pnpjs/sp/items/#get-version-history

@juliemturner Yes but in pnp/js get response only top 50

@juliemturner
Copy link
Collaborator

Did you try adding the .top parameter to versions?

@deep-ponkiya-web
Copy link
Author

deep-ponkiya-web commented Sep 19, 2024

Did you try adding the .top parameter to versions?
@juliemturner

Yes i already Added Top 5000.
but only gives top 50 entries. i need all version history Starting from "1.0".
This is my Version History API Call.

export const getVersionHistory = async (listName: string,selectProperties: string[],expandProperties: string[],ItemID: any) => { const sp: SPFI = getSP(); let queryParams = new GET_LIST_QUERY_PARAMS(); return sp.web.lists.getByTitle(listName).items.select(...selectProperties).expand(...expandProperties).filter(queryParams.filterQuery).orderBy(queryParams.orderByColumn, queryParams.orderBy).top(queryParams.topCount).getAll().then((res) => { return res; }) .catch(async (ex) => { throw ex; }); };

@juliemturner
Copy link
Collaborator

I mean I'm glad you can get version history with that query but I pointed you to the docs where the call is:

const itemVersions: any = await sp.web.lists.getByTitle("My List").items.getById({item id}).versions();

I think you can expand that to:

const itemVersions: any = await sp.web.lists.getByTitle("My List").items.getById({item id}).versions.top(100)();

but I haven't tried that so I can't say for sure.

Also I'd really suggest you move to version 4.

@patrick-rodgers
Copy link
Member

@deep-ponkiya-web - what is the version retention set to on the library? How many versions are you expecting to get?

@deep-ponkiya-web
Copy link
Author

I mean I'm glad you can get version history with that query but I pointed you to the docs where the call is:

const itemVersions: any = await sp.web.lists.getByTitle("My List").items.getById({item id}).versions();

I think you can expand that to:

const itemVersions: any = await sp.web.lists.getByTitle("My List").items.getById({item id}).versions.top(100)();

but I haven't tried that so I can't say for sure.

Also I'd really suggest you move to version 4.

@juliemturner

Yes i tried your solution but only top 50 entries get. Any Other solution?

@deep-ponkiya-web
Copy link
Author

@deep-ponkiya-web - what is the version retention set to on the library? How many versions are you expecting to get?

@patrick-rodgers

i need all version history starting from '1.0' to last change version. i need SharePoint list version history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants