• Maxa
  • NEWBIE
  • 125 Points
  • Member since 2008

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 79
    Replies
When an Opportunity meeting certain criteria is manually closd by a sales person, I would like to have a Contract automatically created and am thinking that a trigger is probably the best way of doing this. Problem being that I am no programmer and looking at the developers guide is like looking at a foreign language text book.

Is building such a trigger a fairly simple exercise and if so, please could some kind soul gently point me in the right direction?

Many thanks.


I have follwing trigger

trigger USP on OpportunityLineItem (after insert) {


 List<Task> task = new List<Task>();
    List<OpportunityLineItem> newOpportunityLineItem = new List<OpportunityLineItem>();
    
    for (Integer i = 0; i < Trigger.new.size(); i++) 
                     { 
                    
                            if (Trigger.new[i].Quantity > 0)

{
                System.debug('triggerfire');
                task.add(new Task(           
                                                      WhatId = Trigger.new[i].OpportunityId,
                                                     OwnerId = Trigger.new[i].Ocid__c,
                                                     Subject='new task'+ Trigger.new[i].Product_Name__c,
                                                     ActivityDate= System.today(),
                                                     ReminderDAteTime = System.Now()

                                                  )
                            );
                  }
        }
     
    insert task;


}

 What it does is that when new product is added to opportunity it creates a task to our support team to insure they follow up on the product and publish it, it  is working fine however, what i need is

 

when a product is entered with multiple quantities for example 2 or 3  etc.

i want to created that number of tasks one for each product, not sure how it is possible without forcing our sales reps to enter one line item for every product but it would be nearly impossible to do

 

any help greatly appreciated

 

  • August 05, 2011
  • Like
  • 0

i Have an issue with my trigger, it is very simple one, basically it takes credit card type and expiry date from payment and put it up one level on Invoice, for reporting purposes. it works fine when a single payment is inserted however when i do bulk upload of new payments i get this error

System.LimitException: Too many DML statements: 151

 

here is my code below any help wpuld be greatly apreciated

trigger CC_Exp on Payment__c (after insert, after update) {
Set<id> objSet = new Set<id>();  

for(Payment__c objOpp:trigger.new)

{

objSet.add(objOpp.Invoice__c);

}

List<Invoice__c> myInvoice = [select Id,Status__c from Invoice__c where Id in: objSet];

for(Payment__c objOpp:Trigger.new)

{

for(Invoice__c objAcc: myInvoice)

{

if (objOpp.Payment_Method__c == 'Credit Card') {

{

objAcc.CC_Expiry_Date__c = objOpp.Expiry_Date__c;//
objAcc.Creditcard_Type__c = objOpp.Credit_card_Type__c;//
update objAcc;
}}}
}}

 

  • July 21, 2011
  • Like
  • 0

HI,

Is there a way i cna delete existing related records under opporttunity such as product, when some oportunity fied changes? how would  go about it? any sample code would be gretly apreciated

  • May 03, 2011
  • Like
  • 0
we woudl like to implement call center for alcatel 4400 PABX, and i'm not sure what woudl be best to you, what sort of adapter and what type of softPhone system, appexcahnge proveds a range of different ones, any one can suggest one?
  • February 03, 2010
  • Like
  • 0

I have piece of code that I can call fine if I connect it to the button, however I would like to automate it with a trigger and I’m not sure how to call my Apex class from the trigger can anyone help?

  • January 13, 2010
  • Like
  • 0
HI,I'm not sure if anyone else had similar problem, but few of our sales reps complained that their task disappear after a while, they pretty sure they log it its their under account but then after a while it's gone, strangely it happens to almost all of them, any one knows the reason? i looked at recycle bin it's not there, i even looked thru backups i do regularly its also done not have any records of any task created, I have already contacted support about this just wondering if anyone else had similar issue.  Max

 

  • December 09, 2009
  • Like
  • 0
Hi,I have leads with specific lead source, and i want automatically add those leads to campaign, but i don’t know how to reference this campaign field, here is what i have so far
Trigger addtonewmember on Lead (after update) {      {        for(lead ld : Trigger.new)        {                               if(ld.rbi_lead_source__c == 'HFNZ')                          ld.Campaign = '701R000000050lw';            }         }    }}
 But it tells me there is no such field as campaign, can anyone help with this is it possible at all?I can add them manually via report

 

  • September 07, 2009
  • Like
  • 0

Hi,

I have industry field in Sf acocunt object, currently i have to manually add new values to it everytime,

is there a way to automate this so it will call out webservice and update the list add new values etc.?

any help would be greatly apreciated

  • July 14, 2009
  • Like
  • 0

hi i'm really puzzled by this issue i think it's somethign very simple but i cannot figure it out :(

i get this error wnen i run this code

acr = cust.AddCustomer( act.id, wbsite, act.name, (act.website==null?'':act.website), ld.description__c, (act.ACN_ABN__c==null?'':act.ACN_ABN__c), (streetline1==null?'':streetline1),//act.BillingStreet, (streetline2==null?'':streetline2),//billingstreet2 (ld.Suburb__c==null?'':ld.Suburb__c), (act.Billingstate==null?'':act.Billingstate), (ld.post_code__c==null?'':ld.post_code__c),//act.BillingPostalCode, act.phone, (act.fax==null?'':act.fax), (con.FirstName==null?'':con.FirstName), (con.LastName==null?'':con.LastName), con.Email, con.Phone);

however if i comment any of those values out

it works just fine

here is example

 

acr1 = cust1.AddCustomer( act.id, wbsite, act.name, (act.website==null?'':act.website), ld.description__c, (act.ACN_ABN__c==null?'':act.ACN_ABN__c), (streetline1==null?'':streetline1),//act.BillingStreet, (streetline2==null?'':streetline2),//billingstreet2 (ld.Suburb__c==null?'':ld.Suburb__c), (act.Billingstate==null?'':act.Billingstate), (ld.post_code__c==null?'':ld.post_code__c),//act.BillingPostalCode, act.phone, (act.fax==null?'':act.fax), con.FirstName, con.LastName, con.Email); // con.Phone);

 

  • June 25, 2009
  • Like
  • 0
has anybody had any problems with their APEX code with summer 09, mine started workgin in really strange way not like it designed to, it completely runs away in a different direction
  • June 15, 2009
  • Like
  • 0
i have an apex class that i woudl like to call when i overide a button, but not sure how to make it, i can make it using on lcik java script but no s controll
  • June 04, 2009
  • Like
  • 0

Hi,

I'm trying to write validation rule to amke sure that only aplha numeric characters are possible in the stree adress field, not sure how to aproach ti.

only way i found was to use contain function, but then i have to write vlaidatino rule for every character

 

Any ideas on more simple way?

  • March 23, 2009
  • Like
  • 0

HI,

I have a triger that creates new task when certain fields in opportunity are changed,

however ic annto deplaoy it because i have no test method.

I have been looking thru the posts here and to be honest i dont get it, in normal apex test method is withing he code, but for trigger its not?

in sll samples i saw there is no reffernce to the trigger or maybe i dont undestand how it suppose to be refferenced.

Here is my trigger below, cna anyone please help me out with a simpe test

trigger assignTask on Opportunity (after update) { List<Task> task = new List<Task>(); List<Opportunity> newOpportunity = new List<Opportunity>(); for (Integer i = 0; i < Trigger.new.size(); i++) { if ((Trigger.new[i].Type == 'New Business')&&(Trigger.new[i].CC_Co_ordinator__c !=null)&&(Trigger.new[i].Finance_Status__c =='Pre-Approved')&&(Trigger.new[i].Optimised_Date__c ==NULL)&& (Trigger.new[i].First_Contact_task_created__c != True)) { System.debug('triggerfire'); task.add(new Task( WhatId = Trigger.new[i].Id, OwnerId=Trigger.new[i].CC_Co_ordinator__c, Subject='First Contact ', ActivityDate = System.today() ) ); } } insert task; }

 

  • March 23, 2009
  • Like
  • 0
Hi,I have created following trigger, this trigger supposed o evaluate opportunity ifType is equal to new business and CC coordinator is not blank it should create new task with subject first contact, but it does not and I have no idea how to fix, can any one help please

trigger assignTask on Opportunity (before insert, before update) { List<Task> task = new List<Task>(); List<Opportunity> newOpportunity = new List<Opportunity>(); for (Integer i = 0; i < Trigger.new.size(); i++) { if ((Trigger.new[i].Type == 'New Business')&&(Trigger.new[i].CC_Co_ordinator__c ==null)) { System.debug('triggerfire'); task.add(new Task( whatid=Trigger.new[i].Id, OwnerId=Trigger.new[i].CC_Co_ordinator__c, Subject='First Contact ' )); } } insert task; }

 

  • March 17, 2009
  • Like
  • 0

Hi,

I have following problem,

i'm trying to create a workflow that will update Subject field in Task based on specific cretiria,

When i get to field update part, it gives me 2 options

blank value

and formula editor

if i use formula editor and put this value in "First Contact"

i get this error

Error: Formula result is data type (Text), incompatible with expected data type (Picklist).

i have this value in my pick list, but SF does not let me choose from pick list

also why woudl it require it? when i create new task via workflow i can put any Subject i like

can anyone help please

  • March 03, 2009
  • Like
  • 0
HI,In our sales process when sales rep adds new product they are presented with a screen,Where that need to enter quantity, start and end dates etc. how would I modify this page to show more custom fields?Any help greatly appreciatedRegards,Max A

 

  • February 17, 2009
  • Like
  • 0
Hi,
Here is my issue
i have a custom button that converts lead, however if specific lead field  is populated i woudl like to be able to disable this button. is it possible? or at least i like to error show up says operation not possible, and prevent from executing the script that is assigned to the button.
 
 
 
Max A
  • January 14, 2009
  • Like
  • 0

Not sure if anyone can help me, I have installed mass converter for leads via app exchange, however when I try following the instruction on how to add custom link to the campaign layout I just cannot see the link there, anyone can help?

Sf labs do not provide any support unfortunately.

 

Max

  • December 11, 2008
  • Like
  • 0

i Have an issue with my trigger, it is very simple one, basically it takes credit card type and expiry date from payment and put it up one level on Invoice, for reporting purposes. it works fine when a single payment is inserted however when i do bulk upload of new payments i get this error

System.LimitException: Too many DML statements: 151

 

here is my code below any help wpuld be greatly apreciated

trigger CC_Exp on Payment__c (after insert, after update) {
Set<id> objSet = new Set<id>();  

for(Payment__c objOpp:trigger.new)

{

objSet.add(objOpp.Invoice__c);

}

List<Invoice__c> myInvoice = [select Id,Status__c from Invoice__c where Id in: objSet];

for(Payment__c objOpp:Trigger.new)

{

for(Invoice__c objAcc: myInvoice)

{

if (objOpp.Payment_Method__c == 'Credit Card') {

{

objAcc.CC_Expiry_Date__c = objOpp.Expiry_Date__c;//
objAcc.Creditcard_Type__c = objOpp.Credit_card_Type__c;//
update objAcc;
}}}
}}

 

  • July 21, 2011
  • Like
  • 0

HI,

Is there a way i cna delete existing related records under opporttunity such as product, when some oportunity fied changes? how would  go about it? any sample code would be gretly apreciated

  • May 03, 2011
  • Like
  • 0

I have piece of code that I can call fine if I connect it to the button, however I would like to automate it with a trigger and I’m not sure how to call my Apex class from the trigger can anyone help?

  • January 13, 2010
  • Like
  • 0
HI,I'm not sure if anyone else had similar problem, but few of our sales reps complained that their task disappear after a while, they pretty sure they log it its their under account but then after a while it's gone, strangely it happens to almost all of them, any one knows the reason? i looked at recycle bin it's not there, i even looked thru backups i do regularly its also done not have any records of any task created, I have already contacted support about this just wondering if anyone else had similar issue.  Max

 

  • December 09, 2009
  • Like
  • 0

Hi guys,

 

I'm trying to figure a way to get our dashboards to auto-refresh each night. Now, given we're running over 100 dashboards, using the Schedule Refresh option isn't an option.

 

Reading up on all of this, I can see there are a couple of javascript ways to trick the browser to issue a refresh on a given dashboard. A little hacky, but seems to be the only way so far I can find.

 

Now I was thinking of using a Http request from Apex to call the "refresh" Url, and hoping Salesforce would issue the refresh (and not be overly worried that the request is not really a browser). I'll assume I need to include cookies and headers in my request with Session IDs and other authentication pieces before this can work. Has anyone used the Http and HttpRequest objects/methods in Apex to call SFDC itself (and managed to authenticate?)

 

Second concern is there is no simple way to query the Dashboards for a list of Dashboard Ids. Sadly, it looks like the only way around this is to define a custom Object, and steal the list of Dashboard Ids out of the Html source straight from Dashboard tab. Has anyone else figured a way to get/query dashboards in Apex?

 

I might try and build a prototype call in apex, and see if I can get the Http request to hit Salesforce and authenticate... but would dearly appreciate some advice if other devs have tried their hand at this before?

 

If successful, glad to share code/walk-through.

 

Cheers,

Vaughan Crole

 

  • December 03, 2009
  • Like
  • 0
Hi,I have leads with specific lead source, and i want automatically add those leads to campaign, but i don’t know how to reference this campaign field, here is what i have so far
Trigger addtonewmember on Lead (after update) {      {        for(lead ld : Trigger.new)        {                               if(ld.rbi_lead_source__c == 'HFNZ')                          ld.Campaign = '701R000000050lw';            }         }    }}
 But it tells me there is no such field as campaign, can anyone help with this is it possible at all?I can add them manually via report

 

  • September 07, 2009
  • Like
  • 0
Hi,I have created following trigger, this trigger supposed o evaluate opportunity ifType is equal to new business and CC coordinator is not blank it should create new task with subject first contact, but it does not and I have no idea how to fix, can any one help please

trigger assignTask on Opportunity (before insert, before update) { List<Task> task = new List<Task>(); List<Opportunity> newOpportunity = new List<Opportunity>(); for (Integer i = 0; i < Trigger.new.size(); i++) { if ((Trigger.new[i].Type == 'New Business')&&(Trigger.new[i].CC_Co_ordinator__c ==null)) { System.debug('triggerfire'); task.add(new Task( whatid=Trigger.new[i].Id, OwnerId=Trigger.new[i].CC_Co_ordinator__c, Subject='First Contact ' )); } } insert task; }

 

  • March 17, 2009
  • Like
  • 0
my apex class method is trying to call an external webservice function, and it gives this
 
Failed to invoke future method 'public static void mycall()'

Debug Log:
System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'
 
any idea of how to fix this? what should I do to make it work?
  • January 14, 2009
  • Like
  • 0
I had some success today refreshing dashboard and thought I'd share. I found some code from SF Heretic on refreshing homepages and dashboards, but it didn't quite work for me, though it got me pointed in the right direction which I greatly appreciate! Their code for refreshing the homepage didn't work for me the way it was setup. What did work was going to Homepage components and adding to the Messages & Alerts:

<meta http-equiv=refresh content=600>

And if you stay on the home page it does refresh after 10 minutes.

What I wanted to do was refresh a dashboard we have for mgmt users whenever they hit that page so they see the current numbers without having to click refresh. What I ended up doing was adding a component to the dashboard that was an S Control and all it contained was the following code where the ID listed is the ID of the dashboard. You can see the exact window open code I lifted below by going to the dashboard and with FIREBUG installed click INSPECT and select the REFRESH button on the page and it will show you something like the below....

Code:
<BODY onLoad="refreshDashboardTimeout();" >
<script>
function refreshDashboardTimeout() {
window.open('/01Z6000000073av—m=poll&refresh=1', 'db_refresh_frame');
}
</script>

Hope that helps some of you out there..........

E





  • May 17, 2007
  • Like
  • 0