How to set URL of workbench and get the list item by ID?

%3CLINGO-SUB%20id%3D%22lingo-sub-1485899%22%20slang%3D%22en-US%22%3EHow%20to%20set%20URL%20of%20workbench%20and%20get%20the%20list%20item%20by%20ID%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1485899%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20a%20newbie%20to%20SharePoint%20development.%20I%20am%20using%20PnP%20JS%20library%20to%20retrieve%20the%20list%20item%20for%20a%20specific%20ID.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CSPAN%20class%3D%22c1%22%3E%2F%2F%20get%20a%20specific%20item%20by%20id(%3CA%20title%3D%22Link%22%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fpnpjs%2Fsp%2Fitems%2F%23get-all-items%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ELINK%3C%2FA%3E%20to%20open%20this)%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22kr%22%3Econst%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3Eitem%3C%2FSPAN%3E%3A%20%3CSPAN%20class%3D%22kt%22%3Eany%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22o%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3Eawait%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3Esp%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22nx%22%3Eweb%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22nx%22%3Elists%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22nx%22%3EgetByTitle%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22s2%22%3E%22My%20List%22%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E).%3C%2FSPAN%3E%3CSPAN%20class%3D%22nx%22%3Eitems%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22nx%22%3EgetById%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22mi%22%3E1%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E).%3C%2FSPAN%3E%3CSPAN%20class%3D%22nx%22%3Eget%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E()%3B%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22nx%22%3Econsole%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22nx%22%3Elog%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22nx%22%3Eitem%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E)%3B%3C%2FSPAN%3E%0A%3C%2FPRE%3E%3CP%3E%26nbsp%3BMy%20requirement%20is%20to%20get%20data%20for%20specific%20ID%20(Like-%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcummins365.sharepoint.com%2Fsites%2FGRP_CC16984%2F_layouts%2F15%2Fworkbench.aspx%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fabc.sharepoint.com%2Fsites%2FSiteNAME%2F_layouts%2F15%2Fworkbench.aspx%3FParam%3D46%3C%2FA%3E)and%20that%20ID%20should%20be%20work%20as%20a%20parameter.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eso%2C%20the%20number%20in%20link%2046%20is%20List%20Item%20ID.%20How%20would%20I%20set%20that%20Param%20inside%20the%20spfx%20webpart%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I am a newbie to SharePoint development. I am using PnP JS library to retrieve the list item for a specific ID. 

 

// get a specific item by id(LINK to open this)
const item: any = await sp.web.lists.getByTitle("My List").items.getById(1).get();
console.log(item);

 My requirement is to get data for specific ID (Like- https://abc.sharepoint.com/sites/SiteNAME/_layouts/15/workbench.aspx?Param=46)and that ID should be work as a parameter.

 

so, the number in link 46 is List Item ID. How would I set that Param inside the spfx webpart?

 

Thank you!

 

 

0 Replies