Error:Input string was not in a correct format. (Javascript)

I’m using SharePoint 2013 online and trying to save an item to a folder content type in a document library I think the code is nearly right but I am getting this error when I hit save button have anyone else had this problem?

Failed Error: Input string was not in a correct format. 

Error on this line.

appContext.executeQueryAsync(function () { 

This is my function ctName is global.

ctName = 'IFUSimon'; function createListItem() {  console.log("1"); if (itemId == 'null') {      var listCreationInformation = new SP.ListItemCreationInformation();     listCreationInformation.set_underlyingObjectType(SP.FileSystemObjectType.folder);     var folderName = $  ('#Title').val();     if (folderName != "") {         listCreationInformation.set_leafName(folderName);     } else {         alert('No title');         return false;     }     listItem = list.addItem(listCreationInformation);     console.log("3");     var listContentTypes = list.get_contentTypes();     console.log("4");     appContext.load(listContentTypes);     console.log("5");     appContext.executeQueryAsync(function () {         console.log("6");         var ct;         console.log("7");         var ct_enumerator = listContentTypes.getEnumerator();         console.log("8");         while (ct_enumerator.moveNext()) {             ct = ct_enumerator.get_current();             if (ct.get_name() == ctName) {                 CTID = ct.get_id();             }         }         listItem.set_item('ContentTypeId', CTID);          console.log("kmr du hitsnart");         setItems();         console.log("kmr du hitsnartklarrrr");     }, fail);   } else {      listItem = item;     console.log("2");     setItems(); } } 

Log from chrome console

1 3 4 5 Failed Error: Input string was not in a correct format. 

UPDATE

I have a very long survey and I am trying to set the item when I save to my content type that is based on folder to set the fields I have used textarea and then

 .set_item('SharePoint column', $  ('#my textarea').val()) 

and the thing is when I press save in SharePoint on the survey I it save all data just like I want and I can read it back the only thing is that it’s set it to wrong content type. And I get Failed Error: Input string was not in a correct format. and it still goes in success.

here is my code to set items

function setItems() {     createListItem();     console.log("15")     listItem.set_item('Title', $  ('#Title').val());     listItem.set_item('GEN_1_Sum_Scope_Assigment', $  ('#GEN_1').val());     listItem.set_item('GEN_1_Sum_Scope_Assigment_D', $  ('#GEN_1_D').val());     listItem.set_item('GEN_2_CRMname', $  ('#GEN_2').val());     listItem.set_item('GEN_2_CRMname_D', $  ('#GEN_2_D').val());     listItem.set_item('GEN_3_F_Mapp', $  ('#GEN_3').val());     listItem.set_item('GEN_3_F_Mapp_D', $  ('#GEN_3_D').val());     listItem.set_item('GEN_4_File_Prio', $  ('#GEN_4').val());     listItem.set_item('GEN_4_File_Prio_D', $  ('#GEN_4_D').val());     listItem.set_item('GEN_5_City', $  ('#GEN_5').val());     listItem.set_item('GEN_5_City_D', $  ('#GEN_5_D').val());     listItem.set_item('GEN_6_During_Operation', $  ('#GEN_6').val());     listItem.set_item('GEN_6_During_Operation_D', $  ('#GEN_6_D').val());     listItem.set_item('GEN_7_Redundancy_Requirements', $  ('#GEN_7').val());     listItem.set_item('GEN_7_Redundancy_Requirements_D', $  ('#GEN_7_D').val());     listItem.set_item('GEN_8_Load', $  ('#GEN_8').val());     listItem.set_item('GEN_8_Load_D', $  ('#GEN_8_D').val());     listItem.set_item('GEN_9_Dimensioned_Effect', $  ('#GEN_9').val());     listItem.set_item('GEN_9_Dimensioned_Effect_D', $  ('#GEN_9_D').val());     listItem.set_item('GEN_10_Rack_nr_Size', $  ('#GEN_10').val());     listItem.set_item('GEN_10_Rack_nr_Size_D', $  ('#GEN_10_D').val());     listItem.set_item('GEN_11_Sketch_Design', $  ('#GEN_11').val());     listItem.set_item('GEN_11_Sketch_Design_D', $  ('#GEN_11_D').val());     listItem.set_item('GEN_12_Req_Fire_Class', $  ('#GEN_12').val());     listItem.set_item('GEN_12_Req_Fire_Class_D', $  ('#GEN_12_D').val());     listItem.set_item('GEN_13_Expansion', $  ('#GEN_13').val());     listItem.set_item('GEN_13_Expansion_D', $  ('#GEN_13_D').val());     listItem.set_item('GEN_14_Existing_Build', $  ('#GEN_14').val());     listItem.set_item('GEN_14_Existing_Build_D', $  ('#GEN_14_D').val());     listItem.set_item('GEN_15_Site_Transport', $  ('#GEN_15').val());     listItem.set_item('GEN_15_Site_Transport_D', $  ('#GEN_15_D').val());     listItem.set_item('GEN_16_Supply_Warranty', $  ('#GEN_16').val());     listItem.set_item('GEN_16_Supply_Warranty_D', $  ('#GEN_16_D').val());     listItem.set_item('GEN_17_Existing_Equipment', $  ('#GEN_17').val());     listItem.set_item('GEN_17_Existing_Equipment_D', $  ('#GEN_17_D').val());     listItem.set_item('GEN_18_Net_Force', $  ('#GEN_18').val());     listItem.set_item('GEN_18_Net_Force_D', $  ('#GEN_18_D').val());     listItem.set_item('GEN_19_BYGG_GOLV', $  ('input[name="GEN19"]:checked').val());     listItem.set_item('GEN_19_BYGG_GOLV_D', $  ('#GEN_19_D').val());     listItem.set_item('GEN_20_EL', $  ('input[name="GEN20"]:checked').val());     listItem.set_item('GEN_20_EL_D', $  ('#GEN_20_D').val());     listItem.set_item('GEN_21_KYL', $  ('input[name="GEN21"]:checked').val());     listItem.set_item('GEN_21_KYL_D', $  ('#GEN_21_D').val());     listItem.set_item('GEN_22_NET', $  ('input[name="GEN22"]:checked').val());     listItem.set_item('GEN_22_NET_D', $  ('#GEN_22_D').val());     listItem.set_item('GEN_23_DRI', $  ('input[name="GEN23"]:checked').val());     listItem.set_item('GEN_23_DRI_D', $  ('#GEN_23_D').val());     listItem.set_item('GEN_24_BRA', $  ('input[name="GEN24"]:checked').val());     listItem.set_item('GEN_24_BRA_D', $  ('#GEN_24_D').val());     listItem.set_item('GEN_25_PERI', $  ('input[name="GEN25"]:checked').val());     listItem.set_item('GEN_25_PERI_D', $  ('#GEN_25_D').val());     listItem.set_item('GEN_26_INR', $  ('input[name="GEN26"]:checked').val());     listItem.set_item('GEN_26_INR_D', $  ('#GEN_26_D').val());     listItem.set_item('GEN_27_ARBETSMOMENT_RISK', $  ('#GEN_27').val());     listItem.set_item('GEN_27_ARBETSMOMENT_RISK_D', $  ('#GEN_27_D').val());     listItem.set_item('GEN_28_Info', $  ('#GEN_28').val());     listItem.set_item('GEN_28_Info_D', $  ('#GEN_28_D').val());     listItem.set_item('KYL_1_Needs', $  ('#KYL_1').val());     listItem.set_item('KYL_1_Needs_D', $  ('#KYL_1_D').val());     listItem.set_item('KYL_2_Moisture_Control', $  ('#KYL_2').val());     listItem.set_item('KYL_2_Moisture_Control_D', $  ('#KYL_2_D').val());     listItem.set_item('KYL_3_Type_Monitor_Interface', $  ('#KYL_3').val());     listItem.set_item('KYL_3_Type_Monitor_Interface_D', $  ('#KYL_3_D').val());     listItem.set_item('KYL_4_Liquid_Alarm_Cable', $  ('#KYL_4').val());     listItem.set_item('KYL_4_Liquid_Alarm_Cable_D', $  ('#KYL_4_D').val());     listItem.set_item('KYL_5_Ventilation', $  ('#KYL_5').val());     listItem.set_item('KYL_5_Ventilation_D', $  ('#KYL_5_D').val());     listItem.set_item('KYL_6_Energy_Saving_Recyckling', $  ('#KYL_6').val());     listItem.set_item('KYL_6_Energy_Saving_Recyckling_D', $  ('#KYL_6_D').val());     listItem.set_item('KYL_7_Existin_Cooling_System', $  ('#KYL_7').val());     listItem.set_item('KYL_7_Existin_Cooling_System_D', $  ('#KYL_7_D').val());     listItem.set_item('KYL_8_Outside_Placement', $  ('#KYL_8').val());     listItem.set_item('KYL_8_Outside_Placement_D', $  ('#KYL_8_D').val());     listItem.set_item('KYL_9_Connection_Points_Border_Demarcation', $  ('#KYL_9').val());     listItem.set_item('KYL_9_Connection_Points_Border_Demarcation_D', $  ('#KYL_9_D').val());     listItem.set_item('KYL_10_Floor_Ceiling', $  ('#KYL_10').val());     listItem.set_item('KYL_10_Floor_Ceiling_D', $  ('#KYL_10_D').val());     listItem.set_item('KYL_11_Info', $  ('#KYL_11').val());     listItem.set_item('KYL_11_Info_D', $  ('#KYL_11_D').val());     listItem.set_item('EL_INFRA_1_Effect_Rack', $  ('#EL_INFRA_1').val());     listItem.set_item('EL_INFRA_1_Effect_Rack_D', $  ('#EL_INFRA_1_D').val());     listItem.set_item('EL_INFRA_2_Rackspaces', $  ('#EL_INFRA_2').val());     listItem.set_item('EL_INFRA_2_Rackspaces_D', $  ('#EL_INFRA_2_D').val());     listItem.set_item('EL_INFRA_3_Equipment_Outside_Elmatas', $  ('#EL_INFRA_3').val());     listItem.set_item('EL_INFRA_3_Equipment_Outside_Elmatas_D', $  ('#EL_INFRA_3_D').val());     listItem.set_item('EL_INFRA_4_Floor_Ceiling', $  ('#EL_INFRA_4').val());     listItem.set_item('EL_INFRA_4_Floor_Ceiling_D', $  ('#EL_INFRA_4_D').val());     listItem.set_item('EL_UPS_1_Time_Battery_Power', $  ('#EL_UPS_1').val());     listItem.set_item('EL_UPS_1_Time_Battery_Power_D', $  ('#EL_UPS_1_D').val());     listItem.set_item('EL_UPS_2_Effect_Operating_Time', $  ('#EL_UPS_2').val());     listItem.set_item('EL_UPS_2_Effect_Operating_Time_D', $  ('#EL_UPS_2_D').val());     listItem.set_item('EL_UPS_3_Battery_Variety', $  ('#EL_UPS_3').val());     listItem.set_item('EL_UPS_3_Battery_Variety_D', $  ('#EL_UPS_3_D').val());     listItem.set_item('EL_UPS_4_Battery_Placement', $  ('#EL_UPS_4').val());     listItem.set_item('EL_UPS_4_Battery_Placement_D', $  ('#EL_UPS_4_D').val());     listItem.set_item('EL_UPS_5_Floor_Type', $  ('#EL_UPS_5').val());     listItem.set_item('EL_UPS_5_Floor_Type_D', $  ('#EL_UPS_5_D').val());     listItem.set_item('EL_UPS_6_Flotation', $  ('#EL_UPS_6').val());     listItem.set_item('EL_UPS_6_Flotation_D', $  ('#EL_UPS_6_D').val());     listItem.set_item('EL_UPS_7_Ventilation', $  ('#EL_UPS_7').val());     listItem.set_item('EL_UPS_7_Ventilation_D', $  ('#EL_UPS_7_D').val());     listItem.set_item('EL_UPS_8_Cooling_Capacity', $  ('#EL_UPS_8').val());     listItem.set_item('EL_UPS_8_Cooling_Capacity_D', $  ('#EL_UPS_8_D').val());     listItem.set_item('EL_UPS_9_Type_Monitor_Interface', $  ('#EL_UPS_9').val());     listItem.set_item('EL_UPS_9_Type_Monitor_Interface_D', $  ('#EL_UPS_9_D').val());     listItem.set_item('EL_UPS_10_Battery_Monitoring_Offereras0', $  ('input[name="ELUPS10"]:checked').val());     listItem.set_item('EL_UPS_10_Battery_Monitoring_Offereras_D', $  ('#EL_UPS_10_D').val());     listItem.set_item('EL_UPS_11_Software_Solution_Atuomatic_Shutdown', $  ('#EL_UPS_11').val());     listItem.set_item('EL_UPS_11_Software_Solution_Atuomatic_Shutdown_D', $  ('#EL_UPS_11_D').val());     listItem.set_item('EL_ResKr_1_Placement_Space', $  ('#EL_RESKR_1').val());     listItem.set_item('EL_ResKr_1_Placement_Space_D', $  ('#EL_RESKR_1_D').val());     listItem.set_item('EL_ResKr_2_Site_Transport', $  ('#EL_RESKR_2').val());     listItem.set_item('EL_ResKr_2_Site_Transport_D', $  ('#EL_RESKR_2_D').val());     listItem.set_item('EL_ResKr_3_Placement_Emergency_Power', $  ('#EL_RESKR_3').val());     listItem.set_item('EL_ResKr_3_Placement_Emergency_Power_D', $  ('#EL_RESKR_3_D').val());     listItem.set_item('EL_ResKr_4_Distance_Location_Truck', $  ('#EL_RESKR_4').val());     listItem.set_item('EL_ResKr_4_Distance_Location_Truck_D', $  ('#EL_RESKR_4_D').val());     listItem.set_item('EL_ResKr_5_Sound_Requirements', $  ('#EL_RESKR_5').val());     listItem.set_item('EL_ResKr_5_Sound_Requirements_D', $  ('#EL_RESKR_5_D').val());     listItem.set_item('EL_ResKr_6_Operating_Time_Emergency_Power', $  ('#EL_RESKR_6').val());     listItem.set_item('EL_ResKr_6_Operating_Time_Emergency_Power_D', $  ('#EL_RESKR_6_D').val());     listItem.set_item('EL_ResKr_7_Exhaust', $  ('#EL_RESKR_7').val());     listItem.set_item('EL_ResKr_7_Exhaust_D', $  ('#EL_RESKR_7_D').val());     listItem.set_item('EL_ResKr_8_Cable_Length_Substations_Auxiliary_Power_Units', $  ('#EL_RESKR_8').val());     listItem.set_item('EL_ResKr_8_Cable_Length_Substations_Auxiliary_Power_Units_D', $  ('#EL_RESKR_8_D').val());     listItem.set_item('EL_ResKr_9_Control_System_Blink', $  ('#EL_RESKR_9').val());     listItem.set_item('EL_ResKr_9_Control_System_Blink_D', $  ('#EL_RESKR_9_D').val());     listItem.set_item('EL_ResKr_10_Typ_Cooling', $  ('#EL_RESKR_10').val());     listItem.set_item('EL_ResKr_10_Typ_Cooling_D', $  ('#EL_RESKR_10_D').val());     listItem.set_item('EL_11_Info', $  ('#EL_11').val());     listItem.set_item('EL_11_Info_D', $  ('#EL_11_D').val());     listItem.set_item('GOLV_1_Drawing', $  ('#GOLV_1').val());     listItem.set_item('GOLV_1_Drawing_D', $  ('#GOLV_1_D').val());     listItem.set_item('GOLV_2_Height', $  ('#GOLV_2').val());     listItem.set_item('GOLV_2_Height_D', $  ('#GOLV_2_D').val());     listItem.set_item('GOLV_3_Stringers', $  ('input[name="GOLV3"]:checked').val());     listItem.set_item('GOLV_3_Stringers_D', $  ('#GOLV_3_D').val());     listItem.set_item('GOLV_4_Cooler_Cutouts', $  ('#GOLV_4').val());     listItem.set_item('GOLV_4_Cooler_Cutouts_D', $  ('#GOLV_4_D').val());     listItem.set_item('GOLV_5_Ventilation_Plate', $  ('#GOLV_5').val());     listItem.set_item('GOLV_5_Ventilation_Plate_D', $  ('#GOLV_5_D').val());     listItem.set_item('GOLV_6_Fire_Seals', $  ('#GOLV_6').val());     listItem.set_item('GOLV_6_Fire_Seals_D', $  ('#GOLV_6_D').val());     listItem.set_item('GOLV_7_Entries', $  ('#GOLV_7').val());     listItem.set_item('GOLV_7_Entries_D', $  ('#GOLV_7_D').val());     listItem.set_item('GOLV_8_Stairs', $  ('#GOLV_8').val());     listItem.set_item('GOLV_8_Stairs_D', $  ('#GOLV_8_D').val());     listItem.set_item('GOLV_9_Solid_Ramp', $  ('#GOLV_9').val());     listItem.set_item('GOLV_9_Solid_Ramp_D', $  ('#GOLV_9_D').val());     listItem.set_item('GOLV_10_Aluminium_Ramp', $  ('input[name="GOLV10"]:checked').val());     listItem.set_item('GOLV_10_Aluminium_Ramp_D', $  ('#GOLV_10_D').val());     listItem.set_item('GOLV_11_Railing', $  ('#GOLV_11').val());     listItem.set_item('GOLV_11_Railing_D', $  ('#GOLV_11_D').val());     listItem.set_item('GOLV_12_Switchgear_Floor', $  ('#GOLV_12').val());     listItem.set_item('GOLV_12_Switchgear_Floor_D', $  ('#GOLV_12_D').val());     listItem.set_item('GOLV_13_Glas_Plate', $  ('#GOLV_13').val());     listItem.set_item('GOLV_13_Glas_Plate_D', $  ('#GOLV_13_D').val());     listItem.set_item('BYGG_1_Build', $  ('#BYGG_1').val());     listItem.set_item('BYGG_1_Build_D', $  ('#BYGG_1_D').val());     listItem.set_item('GOLV_BYGG_1_Info', $  ('#GOLV_BYGG_1').val());     listItem.set_item('GOLV_BYGG_1_Info_D', $  ('#GOLV_BYGG_1_D').val());     listItem.set_item('DRI_1_Sum_Digital_Alarm', $  ('#DRI_1').val());     listItem.set_item('DRI_1_Sum_Digital_Alarm_D', $  ('#DRI_1_D').val());     listItem.set_item('DRI_2_Sum_Analog_Larm', $  ('#DRI_2').val());     listItem.set_item('DRI_2_Sum_Analog_Larm_D', $  ('#DRI_2_D').val());     listItem.set_item('DRI_3_Liquid_Alarms_Included_Cooling_Solution', $  ('#DRI_3').val());     listItem.set_item('DRI_3_Liquid_Alarms_Included_Cooling_Solution_D', $  ('#DRI_3_D').val());     listItem.set_item('DRI_4_Facility_Remote_Monitored_Localy_Display', $  ('#DRI_4').val());     listItem.set_item('DRI_4_Facility_Remote_Monitored_Localy_Display_D', $  ('#DRI_4_D').val());     listItem.set_item('DRI_5_Alarm_Information_Further', $  ('#DRI_5').val());     listItem.set_item('DRI_5_Alarm_Information_Further_D', $  ('#DRI_5_D').val());     listItem.set_item('DRI_6_Personnel_Servicetype', $  ("#DRI_6 option:selected").text());     listItem.set_item('DRI_6_Personnel_Servicetype_D', $  ('#DRI_6_D').val());     listItem.set_item('DRI_7_Personnel_Notification_How', $  ('#DRI_7').val());     listItem.set_item('DRI_7_Personnel_Notification_How_D', $  ('#DRI_7_D').val());     listItem.set_item('DRI_8_Alarm_Supervised_Secure_Line', $  ('#DRI_8').val());     listItem.set_item('DRI_8_Alarm_Supervised_Secure_Line_D', $  ('#DRI_8_D').val());     listItem.set_item('DRI_9_Info', $  ('#DRI_9').val());     listItem.set_item('DRI_9_Info_D', $  ('#DRI_9_D').val());     listItem.set_item('NET_1_Rackspaces', $  ('#NET_1').val());     listItem.set_item('NET_1_Rackspaces_D', $  ('#NET_1_D').val());     listItem.set_item('NET_2_Outlet_Rack_Fiber_Copper', $  ('#NET_2').val());     listItem.set_item('NET_2_Outlet_Rack_Fiber_Copper_D', $  ('#NET_2_D').val());     listItem.set_item('NET_3_NR_Racks_Passive_Active_Com', $  ('#NET_3').val());     listItem.set_item('NET_3_NR_Racks_Passive_Active_Com_D', $  ('#NET_3_D').val());     listItem.set_item('NET_4_Size_KoMM_Rack', $  ('#NET_4').val());     listItem.set_item('NET_4_Size_KoMM_Rack_D', $  ('#NET_4_D').val());     listItem.set_item('NET_5_DuctingChoice', $  ("#NET_5 option:selected").text());     listItem.set_item('NET_5_Ducting_D', $  ('#NET_5_D').val());     listItem.set_item('NET_6_Customer_Ducting', $  ('#NET_6').val());     listItem.set_item('NET_6_Customer_Ducting_D', $  ('#NET_6_D').val());     listItem.set_item('NET_7_Network_Design', $  ('#NET_7').val());     listItem.set_item('NET_7_Network_Design_D', $  ('#NET_7_D').val());     listItem.set_item('NET_8_Internal_Requirements_Specification', $  ('#NET_8').val());     listItem.set_item('NET_8_Internal_Requirements_Specification_D', $  ('#NET_8_D').val());     listItem.set_item('NET_9_Cable_Standard_Specification', $  ('#NET_9').val());     listItem.set_item('NET_9_Cable_Standard_Specification_D', $  ('#NET_9_D').val());     listItem.set_item('NET_10_Rel_Dpt_Groups_Needs', $  ('#NET_10').val());     listItem.set_item('NET_10_Rel_Dpt_Groups_Needs_D', $  ('#NET_10_D').val());     listItem.set_item('NET_11_Incom_Comm_Operator_Location', $  ('#NET_11').val());     listItem.set_item('NET_11_Incom_Comm_Operator_Location_D', $  ('#NET_11_D').val());     listItem.set_item('NET_12_Acces_Critical_Infrastructure', $  ('#NET_12').val());     listItem.set_item('NET_12_Acces_Critical_Infrastructure_D', $  ('#NET_12_D').val());     listItem.set_item('NET_13_Customer_Image_Comm_Network_Operating', $  ('#NET_13').val());     listItem.set_item('NET_13_Customer_Image_Comm_Network_Operating_D', $  ('#NET_13_D').val());     listItem.set_item('NET_14_Equipment_Outside_Connection_Net', $  ('#NET_14').val());     listItem.set_item('NET_14_Equipment_Outside_Connection_Net_D', $  ('#NET_14_D').val());     listItem.set_item('NET_15_Mobile_Covarage_Nesesary', $  ('#NET_15').val());     listItem.set_item('NET_15_Mobile_Covarage_Nesesary_D', $  ('#NET_15_D').val());     listItem.set_item('NET_16_Patch_Cables_Fiber_Copper', $  ('#NET_16').val());     listItem.set_item('NET_16_Patch_Cables_Fiber_Copper_D', $  ('#NET_16_D').val());     listItem.set_item('NET_17_Info', $  ('#NET_17').val());     listItem.set_item('NET_17_Info_D', $  ('#NET_17_D').val());     listItem.set_item('BRA_1_Protection', $  ('#BRA_1').val());     listItem.set_item('BRA_2_Floor_Ceiling', $  ('#BRA_2').val());     listItem.set_item('BRA_3_Protection_Volume', $  ('#BRA_3').val());     listItem.set_item('BRA_4_Fire_Resistance_Density', $  ('#BRA_4').val());     listItem.set_item('BRA_5_Ventilation', $  ('#BRA_5').val());     listItem.set_item('BRA_6_Inergen_Pressure_Relief', $  ('#BRA_6').val());     listItem.set_item('BRA_7_Deviation_Warranties', $  ('#BRA_7').val());     listItem.set_item('BRA_8_Room_Configuration', $  ('#BRA_8').val());     listItem.set_item('BRA_9_Info', $  ('#BRA_9').val());     listItem.set_item('PERI_1_Included_Protection_Types', $  ('#PERI_1').val());     listItem.set_item('PERI_1_Included_Protection_Types_D', $  ('#PERI_1_D').val());     listItem.set_item('PERI_2_Building_Protection_Class', $  ('#PERI_2').val());     listItem.set_item('PERI_2_Building_Protection_Class_D', $  ('#PERI_2_D').val());     listItem.set_item('PERI_3_NR_Room_Building_Indoors_Outdoors', $  ('#PERI_3').val());     listItem.set_item('PERI_3_NR_Room_Building_Indoors_Outdoors_D', $  ('#PERI_3_D').val());     listItem.set_item('PERI_4_Protection_Nr_Doors_Passages', $  ('#PERI_4').val());     listItem.set_item('PERI_4_Protection_Nr_Doors_Passages_D', $  ('#PERI_4_D').val());     listItem.set_item('PERI_5_Perimeter_Locking_System', $  ('#PERI_5').val());     listItem.set_item('PERI_5_Perimeter_Locking_System_D', $  ('#PERI_5_D').val());     listItem.set_item('PERI_6_Info', $  ('#PERI_6').val());     listItem.set_item('PERI_6_Info_D', $  ('#PERI_6_D').val());     listItem.update();     console.log("Knas");     appContext.load(listItem);     appContext.executeQueryAsync(success,fail);     console.log("Knas2");  }   function success() {      console.log('Success');     itemId = listItem.get_id();     console.log("listitem är: " + listItem);     item = listItem; } function fail(sender, args) {     console.log('Failed Error:' + args.get_message()); } 

UPDATE 2

Can’t get it to work this is what I have now know that it’s much but don’t know want to do anymore.

John, i have tried your way but haven’t got it to work to

'use strict';  var appContext, hostweburl, hostContext, parentWeb, list, item, itemId, listId, CTID, listItem, ctTypes, ctName;  appContext = new SP.ClientContext.get_current(); hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl")); listId = decodeURIComponent(getQueryStringParameter("SPListId")); itemId = decodeURIComponent(getQueryStringParameter("SPListItemId")); hostContext = new SP.AppContextSite(appContext, hostweburl); parentWeb = hostContext.get_web(); list = parentWeb.get_lists().getById(listId); item = list.getItemById(itemId);   $  (document).ready(function () {     $  ('#tabs').tabs();     $  (document).tooltip();     $  ('#GEN_4').datepicker({ dateFormat: 'yy-mm-dd' }).val();     $  ('#save').click(setItems);       if (itemId == 'null') {         return;      }     else {         appContext.load(item);         appContext.executeQueryAsync(function () {             var fieldV = item.get_fieldValues();             //var d = fieldV.GEN_4_File_Prio;             //d.setDate(d.getDate() + 1);             $  ('#Title').val(fieldV.Title);             $  ('#GEN_1').val(fieldV.GEN_1_Sum_Scope_Assigment);             //$  ('#GEN_4').val(d.toISOString().substr(0, 10));              //if (fieldV.GEN_19_BYGG_GOLV == true) {             //    $  ('#GEN_19_1').attr('checked', 'checked');             //}             //else {             //    $  ('#GEN_19_2').attr('checked', 'checked');             //}              //$  ('#DRI_6').val(fieldV.DRI_6_Personnel_Servicetype);         }, fail);      }  });     function createListItem() {     console.log("1");      if (itemId == 'null') {        ctName = "CoroCoro";        var itemCreateInfo = new SP.ListItemCreationInformation();         itemCreateInfo.set_underlyingObjectType(SP.FileSystemObjectType.folder);         var folderName = $  ('#Title').val();             if (folderName != "") {                 itemCreateInfo.set_leafName(folderName);             } else {                 alert('No title');                 return false;             }         listItem = list.addItem(itemCreateInfo);         ctTypes = list.get_contentTypes();         appContext.load(ctTypes);         listItem.update();         appContext.load(listItem, "ContentTypeId");         appContext.executeQueryAsync(function () {                 var ct;                 var ct_enumerator = ctTypes.getEnumerator();                 while (ct_enumerator.moveNext()) {                     ct = ct_enumerator.get_current();                     if (ct.get_name() == ctName) {                         CTID = ct.get_id();                     }                 }                listItem.set_item("ContentTypeId", CTID);             listItem.update();             console.log(ctTypes);             appContext.executeQueryAsync(function () { console.log('success') },fail);         }, fail);      }     else {         listItem = item;         console.log("2");         setItems();     }     console.log("13") }  function setItems() {     createListItem();     listItem.set_item('Title', $  ('#Title').val());     listItem.set_item('GEN_1_Sum_Scope_Assigment', $  ('#GEN_1').val());     //listItem.set_item('GEN_4_File_Prio', $  ('#GEN_4').val());     //listItem.set_item('GEN_19_BYGG_GOLV', $  ('input[name="GEN19"]:checked').val());     //listItem.set_item('DRI_6_Personnel_Servicetype', $  ("#DRI_6 option:selected").text());     listItem.update();     appContext.load(listItem);     appContext.executeQueryAsync(success,fail);   }   function success() {      console.log('Success');     itemId = listItem.get_id();     console.log("listitem är: " + listItem);     item = listItem; } function fail(sender, args) {     console.log('Failed Error:' + args.get_message()); }