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
rathi007rathi007 

refresh a standard page through trigger by using a custom class but its not working

my trigger 

// create a trigger on feeditem to update a account field when found '#' in post
trigger CheckChatterPostsOnAccount on FeedItem (After insert)
{

//create a account list
list<account> acclist = new list<account>();

// create a account list
list<account> acclist2 = new list<account>();

// create a set of id
set<id> s = new set<id>();

// insert a new post
for (FeedItem f: trigger.new)
{

// vrifie the condition
if (f.Body.contains('#' ))
{
String parentId = f.parentId;

// add ids in set
s.add(parentId);
}
}
// stote the check__c value from Accounts in list
acclist =[select id,test_check__c from Account where id in:s];

// Iteration of acclist
for(account acc:acclist)
{

// change the status of checkbox
acc.test_check__c =true;
acclist2.add(acc);
}

// update the status
update acclist2;
for(account acc1:acclist)
{
String st=acc1.id;
Refreshclass rc = new Refreshclass();
rc.refresh(st);
}
}

 

and class................................................................................

global class Refreshclass
{
public PageReference refresh(String idd)
{
System.debug(idd);
PageReference pr=new PageReference('https://ap1.salesforce.com/0019000000TSwxo');
System.debug(pr);
return pr;
}
}

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9
That doesnt make any difference.
Just think how is your class linked to standard UI ?

Any guess ?
Nope its not connected and its still in context of trigger

All Answers

Avidev9Avidev9

Well you are making a mistake here!

 

Triggers run on DB level and hence they dont interact with UI or View level. Therefore you cannot referesh a page from an trigger.

 


rathi007rathi007

but trigger goes to my class. but code not work in class

Avidev9Avidev9
That doesnt make any difference.
Just think how is your class linked to standard UI ?

Any guess ?
Nope its not connected and its still in context of trigger
This was selected as the best answer