You need to sign in to do that
Don't have an account?
bhagi
System.Null Pointer Exception:Attemt to De-Reference a null object:trigger.testing Options
i currently want to access mobile number of a user from feeditem i came across the above error ,how can i access it
suggest me.the code was executed but we share something in chatter that time the above error is came
Thanks@Regards
Bhagi
this error comes when there is no value or you are refering a wrong field.
Hi suree
this is my code.and my need is when ever we share something in chatter the user recieve the message their mobile.but this code is working and we share data in chatter it shows the exception
System.Null Pointer Exception:Attemt to De-Reference a null object:trigger.testing Options
please suggest me
trigger Testing on FeedItem (after insert)
{
List<smagicbasic__smsMagic__c> smsObjects = new List<smagicbasic__smsMagic__c>();
List<smagicbasic__smsMagic__c> smsObjects1 = new List<smagicbasic__smsMagic__c>();
String tplText = null;
String query = null;
List<sObject> sObjects = null;
Id FeedItemId = null;
List<CollaborationGroup> esl;
list<CollaborationGroupMember> cgm;
list<user> uu;
list<user> uu1;
list<EntitySubscription> es2;
Id userId = UserInfo.getUserId();
Id orgId = UserInfo.getOrganizationId();
public list<Id> uid = new List<Id>();
public list<Id> uid1 = new List<Id>();
public Set<ID> es1Ids = new Set<ID>();
public Set<ID> es2Ids = new Set<ID>();
for (FeedItem f : Trigger.new)
{
if(f.parentId !=null )
{
esl = [SELECT id, name FROM CollaborationGroup WHERE id =: f.parentId];
system.debug('********** parent id :'+ f.parentid);
es2= [SELECT id, parentid, subscriberid, parent.name FROM EntitySubscription
WHERE parentid = : f.parentid];
for(CollaborationGroup es:esl)
{
cgm = [select id,MemberId from CollaborationGroupMember where CollaborationGroupId = : es.id];
}
}
if(cgm.size()>0)
{
for(CollaborationGroupMember cc : cgm)
{
es1Ids.add(cc.memberid);
}
uu = [select id,MobilePhone,name from user where id IN: es1Ids];
system.debug('**********uuuuuuuuu id :'+uu);
}
System.debug('--- Followers list: ' + uu);
for(EntitySubscription e3:es2)
{
if(e3.subscriberid != null)
{
es2Ids.add(e3.subscriberid);
}
}
uu1 = [select id,MobilePhone,name from user where id IN: es2Ids];
for(user u1 :uu1)
{
if(u1.MobilePhone != null)
{
tplText = f.Body;
smagicbasic__smsMagic__c smsObj = new smagicbasic__smsMagic__c();
smsObj.smagicbasic__PhoneNumber__c = u1.MobilePhone;
smsObj.smagicbasic__SMSText__c = tplText;
smsObj.smagicbasic__senderId__c = 'smsMagic';
smsObj.smagicbasic__Name__c = u1.Name;
smsObjects1.add(smsObj);
}
}
insert smsObjects1;
for(user u :uu)
{
if(u.MobilePhone != null){
system.debug('*********Mobile Phone :'+u.mobilephone);
tplText = f.Body;
smagicbasic__smsMagic__c smsObj = new smagicbasic__smsMagic__c();
smsObj.smagicbasic__PhoneNumber__c = u.MobilePhone;
smsObj.smagicbasic__SMSText__c = tplText;
smsObj.smagicbasic__senderId__c = 'smsMagic';
smsObj.smagicbasic__Name__c = u.Name;
smsObjects.add(smsObj);
}
}
insert smsObjects;
}
}
It looks like this error is comming from some other trigger trigger.testing Options when you are running FeedItem trigger , testing option trigger is also firing (the reason may be both triggers are following same criteria) check with that.
If this answers your question mark it as solution, Its up to you.
no i have only one trigger.
then what is the trigger .testing options
your trigger is testing where as it isshowing trigger.testing opetions, so i asked you to check if you did not get it write some debug logs and check where your value not retrieved.
I hope use try catch exception in the error line
hope it helps
in debug logs also getting error
error:Exec Anon Error
line 1, column 0: required (...)+ loop did not match anything at input 'trigger'
thanks®ards
bhagi
Hi,
You have to make SOQL query on user of list type to get the phone and make the condition i.e. user.Size() > 0 before it is being used inside the code.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.