{"id":2652,"date":"2017-08-21T15:28:04","date_gmt":"2017-08-21T15:28:04","guid":{"rendered":"https:\/\/answers.gurussolutions.com\/answers\/how-to-find-the-internal-id-of-a-custom-record-by-a-specific-field-value-2\/"},"modified":"2026-07-28T18:25:06","modified_gmt":"2026-07-28T18:25:06","slug":"comment-trouver-lidentifiant-interne-dun-enregistrement-personnalise-en-fonction-dune-valeur-de-champ-specifique","status":"publish","type":"qa_entry","link":"https:\/\/answers.gurussolutions.com\/fr\/answers\/comment-trouver-lidentifiant-interne-dun-enregistrement-personnalise-en-fonction-dune-valeur-de-champ-specifique\/","title":{"rendered":"Comment trouver l&rsquo;identifiant interne d&rsquo;un enregistrement personnalis\u00e9 en fonction d&rsquo;une valeur de champ sp\u00e9cifique"},"content":{"rendered":"","protected":false},"template":"","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","ga_subtitle":"Apprenez \u00e0 r\u00e9cup\u00e9rer par programmation l'identifiant interne d'un enregistrement personnalis\u00e9 NetSuite en utilisant la valeur d'un champ comme crit\u00e8re de recherche.","ga_short_answer":"Pour trouver l\u2019identifiant interne d\u2019un enregistrement personnalis\u00e9 en fonction de la valeur d\u2019un champ sp\u00e9cifique, utilisez le module de recherche SuiteScript 2.x de NetSuite. Cr\u00e9ez un filtre de recherche pour le champ personnalis\u00e9 et la valeur souhait\u00e9s, puis lancez la recherche. Parcourez les r\u00e9sultats pour extraire l\u2019identifiant interne de l\u2019enregistrement personnalis\u00e9 correspondant.","ga_scenario":"Un utilisateur doit identifier par programmation l\u2019identifiant interne d\u2019un enregistrement personnalis\u00e9 NetSuite. Cette identification doit s\u2019appuyer sur la valeur d\u2019un champ personnalis\u00e9 sp\u00e9cifique au sein de cet enregistrement, tel que le champ \u00ab SOId \u00bb, afin de r\u00e9cup\u00e9rer l\u2019identifiant unique de l\u2019enregistrement correspondant.","ga_solution":"Pour r\u00e9cup\u00e9rer l\u2019identifiant interne d\u2019un enregistrement personnalis\u00e9 en fonction de la valeur d\u2019un champ sp\u00e9cifique, mettez en \u0153uvre une recherche SuiteScript 2.x. Cela implique de cr\u00e9er un filtre de recherche pour le champ personnalis\u00e9 cible et sa valeur, puis d\u2019ex\u00e9cuter la recherche et d\u2019extraire l\u2019identifiant interne de tout r\u00e9sultat correspondant.L\u2019exemple SuiteScript 2.x suivant illustre la mani\u00e8re d\u2019effectuer cette op\u00e9ration :\n\n```\njavascript\/** * @NApiVersion 2.1 * @NModuleScope SameAccount *\/define(['N\/search'], function(search) {    function getCustomRecordInternalId(customRecordTypeId, customFieldId, fieldValue) {        var internalId = null;        var filters = [];        filters.push(search.createFilter({            name: customFieldId,            operator: search.Operator.IS,            values: fieldValue        }));        var customRecordSearch = search.create({            type: customRecordTypeId, \/\/ e.g., 'customrecord_xxx'            filters: filters,            columns: ['internalid']        });        customRecordSearch.run().each(function(result) {            internalId = result.id; \/\/ Access the internal ID directly            return false; \/\/ Stop after the first match        });        return internalId;    }    \/\/ Example usage:    \/\/ var recordId = getCustomRecordInternalId('customrecord_mycustomrecord', 'custrecord_soid', 'XXX');    \/\/ log.debug('Found Internal ID', recordId);    return {        getCustomRecordInternalId: getCustomRecordInternalId    };});\n```\n\nDans ce script, `customRecordTypeId` doit \u00eatre remplac\u00e9 par l\u2019identifiant de script de votre enregistrement personnalis\u00e9 (par exemple, `customrecord_xxx`), `customFieldId` par l\u2019identifiant du champ personnalis\u00e9 concern\u00e9 (par exemple, `custrecord_soid`), et `fieldValue` par les donn\u00e9es sp\u00e9cifiques que vous recherchez (par exemple, `XXX`). La propri\u00e9t\u00e9 `result.id` permet d\u2019acc\u00e9der directement \u00e0 l\u2019identifiant interne de l\u2019enregistrement personnalis\u00e9 trouv\u00e9 dans les r\u00e9sultats de recherche de SuiteScript 2.x.","ga_source_author":"","ga_source_author_email":"","ga_date_original":"2017-08-21T17:28:04+02:00","ga_date_verified":"2026-07-05","ga_source_subject":"Finding the internal id of a Custom record with a specific field","ga_ans_id":"ANS-0913","ga_publish_decision":"publish_with_edits","ga_staleness_risk":"high","ga_review_priority":"spot_check","ga_tier2_verdict":"partially_outdated","ga_tier2_concerns":"The functions and objects 'nlobjSearchFilter' and 'nlapiSearchRecord' are part of SuiteScript 1.0, which is a legacy version of NetSuite's scripting language.; In current NetSuite environments, SuiteScript 2.x (specifically 2.1) is the recommended standard, utilizing a modular approach (e.g., 'N\/search' module) with different function names like 'search.createFilter' and 'search.create().run().each()' for searching.; While 'getId()' still refers to retrieving an internal ID, its direct application as a method on a search result object in the provided context is specific to SuiteScript 1.0's 'nlobjSearchResult' object.","ga_final_category":"SuiteScript Development","footnotes":""},"ga_category":[108,23,108],"ga_audience":[10],"ga_difficulty":[92],"class_list":["post-2652","qa_entry","type-qa_entry","status-publish","hentry","ga_category-developpement-suitescript","ga_category-suitescript-development","ga_audience-developer-suitescript","ga_difficulty-niveau-intermediaire"],"taxonomy_info":{"ga_category":[{"value":108,"label":"D\u00e9veloppement SuiteScript"},{"value":23,"label":"SuiteScript Development"},{"value":108,"label":"D\u00e9veloppement SuiteScript"}],"ga_audience":[{"value":10,"label":"Developer\/SuiteScript"}],"ga_difficulty":[{"value":92,"label":"Niveau interm\u00e9diaire"}]},"featured_image_src_large":[],"author_info":[],"comment_info":"","_links":{"self":[{"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/qa_entry\/2652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/qa_entry"}],"about":[{"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/types\/qa_entry"}],"version-history":[{"count":1,"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/qa_entry\/2652\/revisions"}],"predecessor-version":[{"id":4572,"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/qa_entry\/2652\/revisions\/4572"}],"wp:attachment":[{"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/media?parent=2652"}],"wp:term":[{"taxonomy":"ga_category","embeddable":true,"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/ga_category?post=2652"},{"taxonomy":"ga_audience","embeddable":true,"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/ga_audience?post=2652"},{"taxonomy":"ga_difficulty","embeddable":true,"href":"https:\/\/answers.gurussolutions.com\/fr\/wp-json\/wp\/v2\/ga_difficulty?post=2652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}