• Brookesy--
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies

Hiya,

 

I was just wondering if its possible to write a trigger that will be able to post both old and new values of a field (Email) to a URL?  E.g Http://superurl.com/bla.aspx?oldemail=123@email.com&newEmail=456@email.com

 

Im pretty sure i can handle the URL bit with HTTPRequest class. 

 

What im wondering is how to access both new and old values in a trigger? I read around and saw that there is a Trigger.Old process i could use through a for loop, would this work? Could i just have one for loop for the old emails, add them to a list, do the same with new emails then put them both through a for loop that visits the URL?

 

Any help or pseudocode would be awesome!!! I apologize for not writing any of my own code in here, but im going to attempt it today and post any i can! :)

 

Thanks

Mike 

 

Edit: So i just realized il need to use @future method because i cant use HTTPRequest while in a trigger :) Meaning il have to pass the old and new triggers values to the class! :) 

Message Edited by Brookesy-- on 02-05-2010 12:41 AM

Hiya,

 

 Im after some advice on what i think is going to be a pretty simple bit of code.  Basically i want to write a trigger on the User object that will insert a record into a separate Staff__c object with details of the user just saved. I was unsure how to pull the details of the user just saved. 

 

Here is some rough pseudo code! Unsure if it would even work with something along these lines? But il give it a try while waiting if anyone else has a better idea :)  (updated code, works even though its rough :) )

 

Just need to work out how to get it to fire only once!

 

 

trigger userToStaff on User (after insert, after update) {

 

List<Staff__c> staffToUpdate = new List<Staff__c>();

 

for (User usr : Trigger.new) {

Staff__c staff = new Staff__c (

//User_ID__c = usr.Id

First_Name__c = usr.Name

);

staffToUpdate.add(staff);

}


 

if(staffToUpdate.size()>0){

try {

insert staffToUpdate;

} catch (exception e) {

system.debug(e.getMessage());

}

}

}

 

 

 

Any advice would be great!!! :)

 

Regards

Michael 

Message Edited by Brookesy-- on 12-21-2009 02:23 AM
Message Edited by Brookesy-- on 12-21-2009 05:33 AM
Message Edited by Brookesy-- on 12-21-2009 05:35 AM
Message Edited by Brookesy-- on 12-21-2009 05:36 AM
Message Edited by Brookesy-- on 12-21-2009 06:20 AM

Im trying to create a simple trigger that writes out the UserId and Date (of the user triggering the trigger) to 2 custom fields.

 

Firstly is it possible to write out the user of the person triggering the trigger?

 

Secondly would something like this work? Trying to get it to trigger when the SS gets changed to 2 - Contact Made. I apologize for my shoddy coding, still learning! :)

 

trigger userForSS2 on Account (after update) { 

 

if(Trigger.isUpdate & myAccount.Sales_Stage__c == '2 - Contact Made'){ myAccount.SQL_User__c = UserInfo.getUserId(); myAccount.SQL_Date__c = date.Today();

}

}

 

 

 

Any help would be great!

Michael 

 

Hiya,

 

 Im after some advice on what i think is going to be a pretty simple bit of code.  Basically i want to write a trigger on the User object that will insert a record into a separate Staff__c object with details of the user just saved. I was unsure how to pull the details of the user just saved. 

 

Here is some rough pseudo code! Unsure if it would even work with something along these lines? But il give it a try while waiting if anyone else has a better idea :)  (updated code, works even though its rough :) )

 

Just need to work out how to get it to fire only once!

 

 

trigger userToStaff on User (after insert, after update) {

 

List<Staff__c> staffToUpdate = new List<Staff__c>();

 

for (User usr : Trigger.new) {

Staff__c staff = new Staff__c (

//User_ID__c = usr.Id

First_Name__c = usr.Name

);

staffToUpdate.add(staff);

}


 

if(staffToUpdate.size()>0){

try {

insert staffToUpdate;

} catch (exception e) {

system.debug(e.getMessage());

}

}

}

 

 

 

Any advice would be great!!! :)

 

Regards

Michael 

Message Edited by Brookesy-- on 12-21-2009 02:23 AM
Message Edited by Brookesy-- on 12-21-2009 05:33 AM
Message Edited by Brookesy-- on 12-21-2009 05:35 AM
Message Edited by Brookesy-- on 12-21-2009 05:36 AM
Message Edited by Brookesy-- on 12-21-2009 06:20 AM

Hiya,

 

 Im after some advice on what i think is going to be a pretty simple bit of code.  Basically i want to write a trigger on the User object that will insert a record into a separate Staff__c object with details of the user just saved. I was unsure how to pull the details of the user just saved. 

 

Here is some rough pseudo code! Unsure if it would even work with something along these lines? But il give it a try while waiting if anyone else has a better idea :)  (updated code, works even though its rough :) )

 

Just need to work out how to get it to fire only once!

 

 

trigger userToStaff on User (after insert, after update) {

 

List<Staff__c> staffToUpdate = new List<Staff__c>();

 

for (User usr : Trigger.new) {

Staff__c staff = new Staff__c (

//User_ID__c = usr.Id

First_Name__c = usr.Name

);

staffToUpdate.add(staff);

}


 

if(staffToUpdate.size()>0){

try {

insert staffToUpdate;

} catch (exception e) {

system.debug(e.getMessage());

}

}

}

 

 

 

Any advice would be great!!! :)

 

Regards

Michael 

Message Edited by Brookesy-- on 12-21-2009 02:23 AM
Message Edited by Brookesy-- on 12-21-2009 05:33 AM
Message Edited by Brookesy-- on 12-21-2009 05:35 AM
Message Edited by Brookesy-- on 12-21-2009 05:36 AM
Message Edited by Brookesy-- on 12-21-2009 06:20 AM

Im trying to create a simple trigger that writes out the UserId and Date (of the user triggering the trigger) to 2 custom fields.

 

Firstly is it possible to write out the user of the person triggering the trigger?

 

Secondly would something like this work? Trying to get it to trigger when the SS gets changed to 2 - Contact Made. I apologize for my shoddy coding, still learning! :)

 

trigger userForSS2 on Account (after update) { 

 

if(Trigger.isUpdate & myAccount.Sales_Stage__c == '2 - Contact Made'){ myAccount.SQL_User__c = UserInfo.getUserId(); myAccount.SQL_Date__c = date.Today();

}

}

 

 

 

Any help would be great!

Michael 

 

Hi

 

Currently after we click the "Save" button in opportunity edit page, the oppty will be saved and redirect to oppty list view page.

I want to create a button in the same page. when I click it, the opportunity will be saved and redirect to Account or other page.

 

Is it possible?

 

Thanks

Kunlun

  • September 19, 2009
  • Like
  • 0

Iv been having some issues getting complete coverage on the piece of code below. Its a simple search feature so people can search for limited information across regions (to assist in sales ops in other countries) You can do a basic search or a loose search.

 

public class CustomerSearchController { String acctName =''; Boolean looseSearch; List <Account> accountsList = new List <Account>(); public Void setacctName(String input) { acctName = input; } public Void setlooseSearch(Boolean input) { looseSearch = input; } public List <Account> getaccountsList() { return accountsList; } public String getacctName() { return null; } public Boolean getlooseSearch() { return null; } public PageReference Search() { accountsList =new List<account>(); if (looseSearch) { for( List <Account> temp : ([select id, name, Owner.Name, Sales_Stage__c, Branch__c from Account where name like: '%'+acctName+'%'])) { accountsList.addAll(temp); } }

else { for( List <Account> temp : ([select id, name, Owner.Name, Sales_Stage__c, Branch__c from Account where name like: acctName+'%'])) { accountsList.addAll(temp); } } return null; } }

 

My test class cant manage to get inside the public PageReference Sarch() method. And i was wondering how i do this? The test class is pretty simple as you can see, but only covers 61% of the code. Everything below the pageref method isnt tested
 
My question is how can i replicate the pagereference information and  fix my test class so that it will cover this code?
 
Any help would be great! 

 

 

@isTest private class CustomerSearchControllerTestMethod { static testMethod void searchControllerTest() { String input = 'Account'; String acctName = input; Boolean looseSearch = True; CustomerSearchController controller = new CustomerSearchController(); controller = new CustomerSearchController(); controller.setacctName('Account'); controller.setlooseSearch(true); controller.getaccountsList(); controller.getacctName(); controller.getlooseSearch(); List <Account> accountsList = new List <Account>(); accountsList = new List<account>(); } }

 

Message Edited by Brookesy on 08-17-2009 06:59 AM