קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
ליצור ולנהל תוויות לקבצים ולתיקיות ב-Drive באמצעות השירות המתקדם 'תוויות' של Google Drive. בעזרת השירות המתקדם הזה, אתם יכולים להשתמש בכל התכונות של Drive Labels API ב-Apps Script.
מידע נוסף על השירות הזה זמין במאמרי העזרה של Google Drive Labels API. בדומה לכל השירותים המתקדמים ב-Apps Script, שירות Drive Labels API משתמש באותם אובייקטים, שיטות ופרמטרים כמו ה-API הציבורי.
כדי לדווח על בעיות ולמצוא תמיכה נוספת, אפשר לעיין במדריך התמיכה של Google Drive Labels API.
/** * List labels available to the user. */functionlistLabels(){letpageToken=null;letlabels=[];do{try{constresponse=DriveLabels.Labels.list({publishedOnly:true,pageToken:pageToken});pageToken=response.nextPageToken;labels=labels.concat(response.labels);}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failed to list labels with error %s',err.message);}}while(pageToken!=null);console.log('Found %d labels',labels.length);}
אחזור של תווית
דוגמת הקוד הבאה מראה איך מקבלים תווית אחת לפי שם המשאב שלה (שהוא ערך המחרוזת של התווית). כדי למצוא את שם התווית, אפשר לקבל את רשימת התוויות דרך ה-API או להשתמש בכלי לניהול תוויות ב-Drive. מידע נוסף על מרכז ניהול התוויות זמין במאמר ניהול תוויות ב-Drive.
/** * Get a label by name. * @param {string} labelName The label name. */functiongetLabel(labelName){try{constlabel=DriveLabels.Labels.get(labelName,{view:'LABEL_VIEW_FULL'});consttitle=label.properties.title;constfieldsLength=label.fields.length;console.log(`Fetched label with title: '${title}' and ${fieldsLength} fields.`);}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failed to get label with error %s',err.message);}}
הצגת תוויות של פריט ב-Drive
בדוגמת הקוד הבאה מוצגות הפעולות לקבלת פריט ב-Drive ולרשימת כל התוויות שהוחלו על הפריט הזה.
/** * List Labels on a Drive Item * Fetches a Drive Item and prints all applied values along with their to their * human-readable names. * * @param {string} fileId The Drive File ID */functionlistLabelsOnDriveItem(fileId){try{constappliedLabels=Drive.Files.listLabels(fileId);console.log('%d label(s) are applied to this file',appliedLabels.labels.length);appliedLabels.labels.forEach((appliedLabel)=>{// Resource name of the label at the applied revision.constlabelName='labels/'+appliedLabel.id+'@'+appliedLabel.revisionId;console.log('Fetching Label: %s',labelName);constlabel=DriveLabels.Labels.get(labelName,{view:'LABEL_VIEW_FULL'});console.log('Label Title: %s',label.properties.title);Object.keys(appliedLabel.fields).forEach((fieldId)=>{constfieldValue=appliedLabel.fields[fieldId];constfield=label.fields.find((f)=>f.id==fieldId);console.log(`Field ID: ${field.id}, Display Name: ${field.properties.displayName}`);switch(fieldValue.valueType){case'text':console.log('Text: %s',fieldValue.text[0]);break;case'integer':console.log('Integer: %d',fieldValue.integer[0]);break;case'dateString':console.log('Date: %s',fieldValue.dateString[0]);break;case'user':constuser=fieldValue.user.map((user)=>{return`${user.emailAddress}: ${user.displayName}`;}).join(', ');console.log(`User: ${user}`);break;case'selection':constchoices=fieldValue.selection.map((choiceId)=>{returnfield.selectionOptions.choices.find((choice)=>choice.id===choiceId);});constselection=choices.map((choice)=>{return`${choice.id}: ${choice.properties.displayName}`;}).join(', ');console.log(`Selection: ${selection}`);break;default:console.log('Unknown: %s',fieldValue.valueType);console.log(fieldValue.value);}});});}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failed with error %s',err.message);}}
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-08-31 (שעון UTC)."],[[["\u003cp\u003eUtilize the Google Drive Labels advanced service in Apps Script to create and manage labels for your Google Drive files and folders, leveraging the Drive Labels API.\u003c/p\u003e\n"],["\u003cp\u003eTo use this advanced service, ensure you enable the Advanced Drive Service in your Apps Script project settings before implementation.\u003c/p\u003e\n"],["\u003cp\u003eAccess comprehensive documentation and support resources for the Google Drive Labels API, which uses the same structure as the public API, in the provided references.\u003c/p\u003e\n"],["\u003cp\u003eExplore the provided sample code snippets to learn how to list available labels, retrieve specific labels by name, and list labels applied to Drive items using Apps Script.\u003c/p\u003e\n"]]],[],null,[]]