var CrmBusinessStatutForm = function(){};

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

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

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

        request.Post(data => {

            data = JSON.parse(data);

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

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

