var CrmProspectTypeForm = function(){};

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

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

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

        request.Post(data => {

            data = JSON.parse(data);

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

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

