var CrmBusinessTypeForm = function(){};

/***
 * Init the form
 * @returns {undefined}
 */
CrmBusinessTypeForm.Init = function(){
    Event.AddById("btnSave", "click", CrmBusinessTypeForm.SaveElement);
};

/***
* Get the Id of element 
*/
CrmBusinessTypeForm.GetId = function(){
    return Form.GetId("CrmBusinessTypeFormForm");
};

/*
* Save the Element
*/
CrmBusinessTypeForm.SaveElement = function(e){
   
    if(Form.IsValid("CrmBusinessTypeFormForm"))
    {
    let request = new Http("CrmBusinessTypeForm", "SaveElement");
        request.SetData(Form.Serialize("CrmBusinessTypeFormForm"));

        request.Post(data => {

            data = JSON.parse(data);

            if(data.status == "error"){
                Form.RenderError("CrmBusinessTypeFormForm", data.data.message);
            } else{

                Form.SetId("CrmBusinessTypeFormForm", data.data.Id);
            }
        });
    }
};

