def setCustomField(mambuentity, customfield="<STR_LIT>", *args, **kwargs):
from . import mambuuser<EOL>from . import mambuclient<EOL>try:<EOL><INDENT>customFieldValue = mambuentity[customfield]<EOL>datatype = [ l['<STR_LIT>']['<STR_LIT>'] for l in mambuentity[mambuentity.customFieldName] if (l['<STR_LIT:name>'] == customfield or l['<STR_LIT:id>'] == customfield) ][<NUM_LIT:0>]<EOL><DEDENT>except IndexError as ierr:<EOL><INDENT>try:<EOL><INDENT>datatype = [ l['<STR_LIT>']['<STR_LIT>'] for l in mambuentity[mambuentity.customFieldName] if (l['<STR_LIT:name>'] == customfield.split('<STR_LIT:_>')[<NUM_LIT:0>] or l['<STR_LIT:id>'] == customfield.split('<STR_LIT:_>')[<NUM_LIT:0>]) ][<NUM_LIT:0>]<EOL><DEDENT>except IndexError:<EOL><INDENT>err = MambuError("<STR_LIT>" % (mambuentity['<STR_LIT:id>'], customfield))<EOL>raise err<EOL><DEDENT><DEDENT>except AttributeError:<EOL><INDENT>err = MambuError("<STR_LIT>")<EOL>raise err<EOL><DEDENT>if datatype == "<STR_LIT>":<EOL><INDENT>mambuentity[customfield] = mambuuser.MambuUser(entid=customFieldValue, *args, **kwargs)<EOL><DEDENT>elif datatype == "<STR_LIT>":<EOL><INDENT>mambuentity[customfield] = mambuclient.MambuClient(entid=customFieldValue, *args, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>mambuentity[customfield] = customFieldValue<EOL>return <NUM_LIT:0><EOL><DEDENT>return <NUM_LIT:1><EOL>
Modifies the customField field for the given object with
    something related to the value of the given field.

    If the dataType == "USER_LINK" then instead of using the value
    of the CF, it will be a MambuUser object.

    Same if dataType == "CLIENT_LINK", but with a MambuClient.

    Default case: just uses the same value the CF already had.

    Returns the number of requests done to Mambu.