تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يمكنك إنشاء تصنيفات لملفاتك ومجلداتك في Drive وإدارتها باستخدام الخدمة المتقدّمة "التصنيفات" في Google Drive. باستخدام هذه الخدمة المتقدّمة، يمكنك استخدام كل
ميزات
Drive Labels API
في Apps Script.
لمزيد من المعلومات عن هذه الخدمة، يُرجى الاطّلاع على مستندات
Google Drive Labels API. مثل جميع الخدمات المتقدمة
في Apps Script، تستخدم خدمة Drive Labels API العناصر
والطُرق والمَعلمات نفسها المستخدَمة في واجهة برمجة التطبيقات العامة.
للإبلاغ عن المشاكل والعثور على دعم آخر، يُرجى الاطّلاع على دليل الدعم الخاص بواجهة برمجة التطبيقات Google Drive Labels API.
نموذج التعليمات البرمجية
يستخدِم نموذج الرمز البرمجي أدناه
الإصدار 2 من
واجهة برمجة التطبيقات.
إدراج التصنيفات
يوضّح نموذج الرمز البرمجي التالي كيفية الحصول على قائمة بالتصنيفات المتاحة
للمستخدم الذي يقدّم الطلب.
/** * 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('Failedtolistlabelswitherror%s',err.message);}}while(pageToken!=null);console.log('Found%dlabels',labels.length);}
الحصول على تصنيف
يوضّح نموذج الرمز البرمجي التالي كيفية الحصول على تصنيف واحد من خلال
اسم المورد
(وهو القيمة السلسلة للتصنيف). للعثور على اسم التصنيف، احصل على قائمة
بالتصنيفات من خلال واجهة برمجة التطبيقات أو استخدِم أداة إدارة تصنيفات 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(`Fetchedlabelwithtitle:'${title}'and${fieldsLength}fields.`);}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failedtogetlabelwitherror%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('%dlabel(s)areappliedtothisfile',appliedLabels.labels.length);appliedLabels.labels.forEach((appliedLabel)=>{// Resource name of the label at the applied revision.constlabelName='labels/'+appliedLabel.id+'@'+appliedLabel.revisionId;console.log('FetchingLabel:%s',labelName);constlabel=DriveLabels.Labels.get(labelName,{view:'LABEL_VIEW_FULL'});console.log('LabelTitle:%s',label.properties.title);Object.keys(appliedLabel.fields).forEach((fieldId)=>{constfieldValue=appliedLabel.fields[fieldId];constfield=label.fields.find((f)=>f.id==fieldId);console.log(`FieldID:${field.id},DisplayName:${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('Failedwitherror%s',err.message);}}
تاريخ التعديل الأخير: 2025-06-05 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-06-05 (حسب التوقيت العالمي المتفَّق عليه)"],[[["Utilize 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."],["To use this advanced service, ensure you enable the Advanced Drive Service in your Apps Script project settings before implementation."],["Access comprehensive documentation and support resources for the Google Drive Labels API, which uses the same structure as the public API, in the provided references."],["Explore 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."]]],[]]