You need to sign in to do that
Don't have an account?

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

Just like it says, "Number" is not a valid data type. You probably want Integer, Decimal, Double or Long.