Issue on import Account parent company column

Dear community

 

I tried to import the Account.Parent column the import is finished without error, but in the "connect to" tab of page account no relationship between the two account imported is showed.

I checked in the RelationshipConnection table and no records are imported.

In the past on a environment with 7.16 version everything worked fine.

What Do I'm doing wrong?

 

Like 0

Like

5 comments

The new Connected To tab in 7.17 doesn't use the Parent column on the account - it has a new table structure that works for both accounts and contacts. You can add the previous Connected To detail on the page and it will show the account relationships using the Parent column. 

Ryan

Dear Stefano,

 

Thank you for your question!

 

You may feel free to refer to Ryan`s answer above.

 

Ryan, thank you very much for your dedication!

 

Have a great day team!

 

Regards,

Danyil

Danyil Onoprienko,

 

thank you all,

If I would like to use the new features which tables should I import ?

This is an sql script that creates for an account with parent column set the right records in the new relationship tables.

DO $$ 
declare
  SchemaId uuid;
  AuthorId uuid := '410006e1-ca4e-4502-a9ec-e54d922d2c00'; -- supervisor
  RelationTypeId uuid;
begin 
    -- Get Schema Account
    SELECT "UId"
    FROM "SysSchema"
    WHERE "Caption" = 'Account'
        AND "ExtendParent" = false
    INTO SchemaId;
 
    -- Get relation
    SELECT "Id"
    FROM "RelationType"
    WHERE "Name" = 'Holding company'
    INTO RelationTypeId;
 
    CREATE TEMP TABLE "Entities" (
        "EntityIdA" uuid
        , "EntityIdB" uuid
        , "RelationshipDiagramId" uuid
        , "AuthorId" uuid
        , "RelationshipEntityAId" uuid
        , "RelationshipEntityBId" uuid
        );
 
    INSERT INTO "Entities" (
        "EntityIdA"
        , "EntityIdB"
        , "RelationshipDiagramId"
        , "AuthorId"
        , "RelationshipEntityAId"
        , "RelationshipEntityBId"
        )
    SELECT a."ParentId" AS "EntityIdA"
        , a."Id" AS "EntityIdB"
        , uuid_generate_v4() AS "RelationshipDiagramId"
        , AuthorId AS "AuthorId"
        , NULL AS "RelationshipEntityAId"
        , NULL AS "RelationshipEntityBId"
    FROM "Account" a
    WHERE a."ParentId" IS NOT NULL
        AND NOT EXISTS (
            SELECT 1
            FROM "RelationshipConnection" rc
            JOIN "RelationshipEntity" ea
                ON rc."RelationshipEntityAId" = ea."Id"
            JOIN "RelationshipEntity" eb
                ON rc."RelationshipEntityBId" = eb."Id"
            where ea."RecordId" = a."ParentId"
            and eb."RecordId" = a."Id"
            );
 
    INSERT INTO "RelationshipDiagram" (
        "Id"
        , "CreatedById"
        , "ModifiedById"
        )
    SELECT ee."RelationshipDiagramId"
        , ee."AuthorId" AS CreatedById
        , ee."AuthorId" AS ModifiedById
    FROM "Entities" ee;
 
    -- Entity A
    INSERT INTO "RelationshipEntity" (
        "RecordId"
        , "CreatedById"
        , "ModifiedById"
        , "SchemaUId"
        )
    SELECT ee."EntityIdA"
        , AuthorId AS CreatedById
        , AuthorId AS ModifiedById
        , SchemaId
    FROM "Entities" ee
    WHERE NOT EXISTS (
            SELECT 1
            FROM "RelationshipEntity" re
            WHERE re."RecordId" = ee."EntityIdA"
            );
 
    -- Entity B
    INSERT INTO "RelationshipEntity" (
        "RecordId"
        , "CreatedById"
        , "ModifiedById"
        , "SchemaUId"
        )
    SELECT ee."EntityIdB"
        , AuthorId AS CreatedById
        , AuthorId AS ModifiedById
        , SchemaId
    FROM "Entities" ee
    WHERE NOT EXISTS (
            SELECT 1
            FROM "RelationshipEntity" re
            WHERE re."RecordId" = ee."EntityIdB"
            );
 
    -- Update data in temp table
    UPDATE "Entities" ee
    SET "RelationshipEntityAId" = re."Id"
    FROM "RelationshipEntity" re
    WHERE ee."EntityIdA" = re."RecordId";
 
    UPDATE "Entities" ee
    SET "RelationshipEntityBId" = re."Id"
    FROM "RelationshipEntity" re
    WHERE ee."EntityIdB" = re."RecordId";
 
    -- RelationEntInDiagram
    INSERT INTO "RelationEntInDiagram" (
        "CreatedById"
        , "ModifiedById"
        , "RelationshipDiagramId"
        , "RelationshipEntityId"
        )
    SELECT ee."AuthorId" AS CreateById
        , ee."AuthorId" AS ModifiedBy
        , ee."RelationshipDiagramId"
        , ee."RelationshipEntityAId"
    FROM "Entities" ee;
 
    -- RelationEntInDiagram
    INSERT INTO "RelationEntInDiagram" (
        "CreatedById"
        , "ModifiedById"
        , "RelationshipDiagramId"
        , "RelationshipEntityId"
        )
    SELECT ee."AuthorId" AS CreateById
        , ee."AuthorId" AS ModifiedBy
        , ee."RelationshipDiagramId"
        , ee."RelationshipEntityBId"
    FROM "Entities" ee;
 
    -- RelationshipConnection
    INSERT INTO "RelationshipConnection" (
        "RelationshipEntityAId"
        , "RelationshipEntityBId"
        , "RelationTypeId"
        )
    SELECT ee."RelationshipEntityAId"
        , ee."RelationshipEntityBId"
        , RelationTypeId AS RelationTypeId
    FROM "Entities" ee;
 
DROP TABLE "Entities";
 
end $$;

 

Stefano Bassoli,

This is fantastic! Thanks for sharing this Stefano!

Ryan

Show all comments