How to remove all linked records from a link group?

Daniel Manocchio
Daniel Manocchio Member Posts: 22
5 Likes First Comment Photogenic

Hi Guys,

I'm struggling with clearing a static record link group from all records. For clearing attributes, there is the method record.clear_attributes([names]), but I didn't find something similar for static link groups. I've already tried
record.set_links(link_name='rlg_name', records=[])
but this didn't change anything on the server.

Any hints how to get rid of all records in a given record link group?

Thanks in advance & bests,

Best Answer

  • Andy_Grigg
    Andy_Grigg Member, Employee Posts: 27
    Name Dropper First Answer First Comment First Anniversary
    Answer ✓

    Hi Daniel,

    I think you've found a bug in how we handle link group changes. The code you've written is essentially correct, it should be:

    record.set_links(link_name='rlg_name', records=[])
    mi.update([record], update_links=True)

    But this only works if at least one link is added to the link group. I'll double-check with my colleagues tomorrow if there's an intended alternative way of doing this, but to me it looks like a bug.

    As a workaround, you can use the foundation layer to do the link deletion. Something like this should work:

    gdl_session = mi.connect()
    record_reference = gdl.RecordReference(
        historyGUID="history guid",  # Or another identifier
    unlink_records = gdl.UnlinkAllRecords(sourceRecords=[record_reference])
    modifications = gdl.RecordLinkModifications(unlinkAllRecords=[unlink_records])
    link_reference = gdl.RecordLinkGroupReference(
        name="Link group name",
        partialTableReference=gdl.PartialTableReference(tableName="Table name"),
        recordLinkGroupType=gdl.GRANTA_Constants.RecordLinkGroupTypes.Static,  # Or CrossDatabase
    unlink_request = gdl.ModifyRecordLinksRequest(
    response = gdl_session.dataImportService.ModifyRecordLinks(unlink_request)


  • Daniel Manocchio
    Daniel Manocchio Member Posts: 22
    5 Likes First Comment Photogenic

    Hi Andy,

    Thanks for your answer! :smile: I already feared that this isn't intended behavoir but a bug... g
    I'll give it a try with the foundation snippet.