Sync Tables fails without an error in Pack Maker tools - Retrieve Coda user

Hi Team,

I am writing a pack to return the salesforce user as coda user. pfb my code snippet

// A User schema defining the data in the sync table.
const UserTestSchema = coda.makeObjectSchema({
  codaType: coda.ValueHintType.Person,
  properties: {
    email: {
      description: "Email of the User.",
      type: coda.ValueType.String,
      required: true,
    },
    name: {
      description: "The Username of the User.",
      type: coda.ValueType.String,
    },
  },
  displayProperty: "name",
  idProperty: "email",
  featuredProperties: ["name", "email"],
  identity: {
    name: "UserTest",
  },
});

//Table to sync salesforce Users with Coda
pack.addSyncTable({
  name: "UsersTest",
  schema: UserTestSchema,
  identityName: "UserTest",
  formula: {
    name: "SyncUsersTest",
    description: "Sync Users Table",
    parameters: [],
    execute: async function ([], context) {

      let listUrl = salesforce_account + salesforce_query + "SELECT+ID+from+User";

      let response = await context.fetcher.fetch({
        method: "GET",
        url: listUrl,
        cacheTtlSecs: 0,
      });
      let results = response.body.records;


      let userResults = await iterateUsersTest(context.fetcher, results);

      return {
        result: userResults,
      };
    },
  },
});

It is properly fetching the results and is not rendered in coda sync table saying the sync failed. There is no error in the logs. Any help in resolving the issue. Thanks in Advance.

Thanks,
Elam

Hi @Elam_Jaybal - Looking back at the documentation on Person references I can see how I didn’t provide quite enough information. The schema you defined looks fine, but it’s mean to be used within a property of a larger schema that represents a sync table row.

const PersonSchema = coda.makeObjectSchema({
  codaType: coda.ValueHintType.Person,
  // ...
});

const BookSchema = coda.makeObjectSchema({
  properties: {
    title: { type: coda.ValueType.String },
    author: PersonSchema,
  }
});

pack.addSyncTable({
  name: "Books",
  schema: BookSchema,
  // ...
});

In that example each row in the “Books” sync table would have a “Title” columns with text and a “Author” column with the person chip. Let me know if that helps clear up the intended usage.

2 Likes

Hi Eric,

Thanks for the quick response. Let me work out and get back to you.

Thanks,
Elam

Hi @Eric_Koleda

Thanks for your help. It works fine. The syntax was described in the referenced data type. I missed checking from that. Sorry for that. Thanks again.

Thanks,
Elam

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.