Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

279
Views
Obtenga un elemento de lista específico con SPFX y PNP/JS y muéstrelo en SharePoint Online Webpart/Widget

Quiero leer los valores de un elemento de lista específico por ID y mostrarlo en un sitio de SharePoint.

El problema es que traté de usar PNP Framework, pero algunos de los componentes ya no funcionan. Aquí está mi código hasta ahora. Espero que puedas ayudarme.

 import * as React from 'react'; import styles from './Webpartprojectsw.module.scss'; import { IWebpartprojectswProps } from './IWebpartprojectswProps'; import { escape } from '@microsoft/sp-lodash-subset'; import * as jquery from 'jquery'; import { IItemAddResult, DateTimeFieldFormatType } from "@pnp/sp/presets/all"; import { spfi, SPFI, SPFx } from "@pnp/sp"; import "@pnp/sp/webs"; import "@pnp/sp/lists"; import "@pnp/sp/items"; export interface ISolypProjectListItemsState{ Title: string, ID: number, StartDate: string, EndDate:string, ProjectPhase: string, TrafficLight:string, message: string } export default class Webpartprojectsw extends React.Component<IWebpartprojectswProps,ISolypProjectListItemsState> { public static siteurl: string=""; public constructor(props:IWebpartprojectswProps, state: ISolypProjectListItemsState){ super(props); this.state={ Title:"", ID:0, StartDate:"", EndDate:"", ProjectPhase:"", TrafficLight:"", message:"" }; Webpartprojectsw.siteurl= this.props.websiteurl; } public componentDidMount() { this._ReadItem(); } public render(): React.ReactElement<IWebpartprojectswProps> { return ( <div> {this.state.message} {this.state.Title} </div> ); } private async _ReadItem(){ // get a specific item by id const item: any = await sp.web.lists.getByTitle("ProjectStatusList").items.getById(1).get(); console.log(item); this.setState({message:"Last Item Created Title:--> " + item.Title + item.TrafficLight}); } }

¡Muchos gracias!

Matías

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!