function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
HelloSanHelloSan 

unable to create map with datatype id and number

trigger AutoNoOfStud on Hostel__c (After Insert,After Update,After Delete) 
{
if(trigger.isinsert)
{
Map<Id,number> map1=new Map<Id,Number>();
list<student__c> st1=new list<student__c>();
list<hostel__c> ht1=trigger.new;
for(hostel__c ht:ht1)
{
map1.put(ht.id,ht.no_of_stud__c);
}
if(map1.size()>0&&map1!=null)
{
for(Id hid:map1.keyset())
{
for(integer i=0;i<map1.get(hid);i++)
{
student__c st=new student__c();
st.name='Indian Student '+'i';
st.phone__c='0406666';
st.lagnguage__c='telugu';
st.ref_hostel__c=hid;
st1.add(st);
}
}
if(st1.size()>0&& size!=null)
{
insert st1;
}
}
}
}
 

Error: Compile Error: Invalid type: Number at line 5 column 32
davidjgriffdavidjgriff
Just like it says, "Number" is not a valid data type. You probably want Integer, Decimal, Double or Long.