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

328
Views
Forge Viewer: getExternalIdMapping() to return only certain dbIds from certain externalIds
this.viewer.model.getExternalIdMapping(data => console.log(data))

This particular line gets everything. But I only need the dbIds of certain externalIds. How can I do that?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

A few ways depending on what exactly you need. Here's what I've done.

function getDbIdFromExternalId(externalIds) {
    return new Promise((resolve) => {
      viewer.model.getExternalIdMapping((d) => {
        //console.log("getDbIdFromExternalId Executed");
        let responseArr = [];
        externalIds.forEach(externalId => {
            if(d[externalId]) responseArr.push([d[externalId], externalId]);
        });
        resolve(responseArr);
      });
    });
}
/*Your external IDs in here*/
var externalIds = ['23287','23292','23291'];
/*response is set here*/
var response = await getDbIdFromExternalId(externalIds);

Expected value of response (with my autocad viewer): [[39675,"23292"],[39674,"23291"]]

That way you can see the pair. Notice I threw in a value that didn't map to anything, so the array was only populated with what it found.

about 4 years ago · Juan Pablo Isaza Report

0

Another option would be to implement your own user function and calling the getExternalIdMapping method of the property database that can actually be filtered for specific external IDs:

function mapMyExternalIds(model, externalIds) {
  const filter = {};
  for (const externalId of externalIds) {
    filter[externalId] = true;
  }
  return model.getPropertyDb().executeUserFunction(function userFunction(pdb, filter) {
    return pdb.getExternalIdMapping(filter);
  }, filter);
}

Then you can use it like so:

mapMyExternalIds(NOP_VIEWER.model, ["6949fe39-3e9a-4d4d-b7fe-71339c615138-00022318"])
  .then(map => console.log(map))
  .catch(err => console.error(err));
about 4 years ago · Juan Pablo Isaza Report
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!