RIR - Walls - Allow disallow joins

Hello,
I am trying to adapt the following Allow/Disallow joins script I have found in the forum related to structural framing to walls, with no luck.

WU = DB.WallUtils

t = DB.Transaction(doc, 'Update End Joins')
t.Start()
try:
    if isinstance(E, DB.FamilyInstance):
        # if wall
        if True:
            for state, endidx in zip([JS, JE], [0, 1]):
                print(state, endidx)
                if state:
                    SFU.AllowWallJoinAtEnd(E, endidx)
                else:
                    SFU.DisallowWallJoinAtEnd(E, endidx)
    t.Commit()
except Exception as txn_err:
    show_error(str(txn_err))
    t.RollBack()

Anyone who can help, please?
thanks

Hey, hope the below should work… let’s know how it goes