'Change to update if this request attempts to create a
duplicate entry in a link table
@param request: the request
@param record_id: the record ID'

def deduplicate_link(self, request, record_id):

    linked = self.resource.linked
    table = self.table
    session = current.session
    if ((request.env.request_method == 'POST') and (linked is not None)):
        pkey = table._id.name
        post_vars = request.post_vars
        if (not post_vars[pkey]):
            lkey = linked.lkey
            rkey = linked.rkey
            _lkey = post_vars[lkey]
            _rkey = post_vars[rkey]
            query = ((table[lkey] == _lkey) & (table[rkey] == _rkey))
            row = current.db(query).select(table._id, limitby=(0, 1)).first()
            if (row is not None):
                tablename = self.tablename
                record_id = row[pkey]
                formkey = session.get(('_formkey[%s/None]' % tablename))
                formname = ('%s/%s' % (tablename, record_id))
                session[('_formkey[%s]' % formname)] = formkey
                post_vars['_formname'] = formname
                post_vars[pkey] = record_id
    return record_id
