How to clear a relationship field

So how do you CLEAR a relationship field that has a value in it?  I tried

this.model.set('whatevercontracts_accountsaccounts_ida', '')
this.model.set('whatevercontracts_accounts_name', '');

but that doesn't really work, it seems to leave the name in place.  If I d
this.model.set('whatevercontracts_accountsaccounts_ida', '')
this.model.set('whatevercontracts_accounts_name', ' ');

(see space in the name), that clears the name but doesn't really reset the field.
Parents Reply Children
  • Yes, you can clear the field from the create view but we have fields that are related to that field and I want them to clear all at the same time.  Once you clear the parent relationship, I need related relationships to be cleared as well as they are now wrong.  I found the code that does it, you have to clear them both and then re-render the field.


    this.clearAllFields=function(self)
    {

            //Clear the partner contact
            self.model.unset('in_customer_contacts_cases_1_name');
              self.model.unset('in_customer_contacts_cases_1in_customer_contacts_ida');
              fieldRef = self.getField('in_customer_contacts_cases_1_name');
              fieldRef.render();

                    //clear the customer contact
              self.model.unset('contacts_cases_1_name');
              self.model.unset('contacts_cases_1contacts_ida');
              fieldRef = self.getField('contacts_cases_1_name');
              fieldRef.render();

                    //clear related address and phone fields
              self.model.set('service_address_street_c', '');
              self.model.set('service_address_city_c', '');
              self.model.set('service_address_state_c', '');
              self.model.set('service_address_postalcode_c', '');
              self.model.set('star2star_locationdid_c', '');
              self.model.set('customer_contact_phone_numbe_c', '');

              self.model.set('partner_contact_phone_number_c', '');
              self.model.set('partner_contact_email_c', '');
              self.model.set('customer_contact_email_c', '');
              self.model.set('customer_contact_phone_numbe_c', '');
              self.model.set('customer_contact_email_c', '');
              self.model.set('call_back_name_c', '');
              self.model.set('call_back_number_c', '');
              sessionStorage.removeItem('call_back_name_c');
              sessionStorage.removeItem('call_back_number_c');
         };