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
bhagibhagi 

Regarding Chatter

hi,

my need is we share something in chatter by using @ function  particular users only recieve the message their mobiles(using of sms magic application).

i write the trigger its working but the sms will be going multiple users..

can anyone help me..please

 

trigger bouncedTrigger66 on FeedItem (after insert) {
        List<smagicbasic__smsMagic__c> smsObjects = new List<smagicbasic__smsMagic__c>();
        String tplText = null;
        String query = null;
        List<sObject> sObjects = null;
        Id leadId = null;
        EntitySubscription es;
        list<user> uu;
        Id userId = UserInfo.getUserId();
        Id orgId = UserInfo.getOrganizationId();
for (FeedItem f : Trigger.new)
{
      String parentId = f.parentId;
    if(parentid!=null)

    {
    es = [SELECT id, parentid, subscriberid, parent.name FROM EntitySubscription WHERE parentid = : parentid];
     if(es.subscriberid!=null)

       {
     uu = [select id,MobilePhone,name from user where id = :es.subscriberid];
       }

     }
      for(user u :uu)
       {
        if(u.MobilePhone != null){
        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;
}

 

Thanks&Regards

bhagi

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Jia HuJia Hu
first change EntitySubscription es to List<EntitySubscription> es
then revise the code around if(es.subscriberid!=null)

for details, please see http://boards.developerforce.com/t5/Chatter-and-Chatter-API/Compile-Error-Invalid-foreign-key-relationship-FeedItem/td-p/456735

All Answers

Jia HuJia Hu
Is this the same with the post on:

Compile Error: Invalid foreign key relationship: FeedItem.FeedTracking a
http://boards.developerforce.com/t5/Chatter-and-Chatter-API/Compile-Error-Invalid-foreign-key-relationship-FeedItem/m-p/458579#M2113
bhagibhagi

yes jaihu.what i wil do??can u suggest me?

Jia HuJia Hu
How you confirmed my recent reply in the previous post, and does it work for you?
bhagibhagi

i am also facing that problem.so...

Jia HuJia Hu
first change EntitySubscription es to List<EntitySubscription> es
then revise the code around if(es.subscriberid!=null)

for details, please see http://boards.developerforce.com/t5/Chatter-and-Chatter-API/Compile-Error-Invalid-foreign-key-relationship-FeedItem/td-p/456735
This was selected as the best answer
bhagibhagi

Thank you jai hu.

 

Its working.the error is rectified.but we share something in chatter the user unable to recieve the message thier mobile.