• sammy9099
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 38
    Replies

Hi All , 

 

This is the second time , I am posting this issue . But No one has been able to provide any concrete solution. Please help,

 

I have created a custom with javascript functionality and its working fine . I want when the same button is pressed twice or thrice  it should give alert message " Invalid action". I tried  using lot of things but its not working. I know it looks very easy but pls help me out in this issue. TBelow is the script:-

 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

 

var leadstatus = '{!Lead.Status}';
if (leadstatus != "Z-Program Approved")
{
alert('An Elite name cannot be assigned unless the Lead Status is equal Z-Program Approved');
}

else{

// Now calling the webservice to create a new Id 
var callback = "" + sforce.apex.execute("CreateliteId","createlite", {LeadId:"{!Lead.Id}"});

// If create and update was ok - just reload Lead page to see the id of the elite partner
if(callback == 'OK' ){

alert('The Elite Id has been assigned');
window.location.reload();
}

 

else{
alert('Error: ' + callback);
}}

Hi All , 

 

I have created a custom with javascript functionality and its working fine . I want when the same button is pressed twice or thrice  it should give alert message " Invalid action". I tried  using lot of things but its not working. I know it looks very easy but pls help me out in this issue. Below is the script:-

 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

 

var leadstatus = '{!Lead.Status}';
if (leadstatus != "Z-Program Approved")
{
alert('An Elite Id cannot be assigned unless the Lead Status is equal Z-Program Approved');
}

else{

// Now calling the webservice to create a new Id 
var callback = "" + sforce.apex.execute("CreateliteId","createlite", {LeadId:"{!Lead.Id}"});

// If create and update was ok - just reload Lead page to see the id of the elite partner
if(callback == 'OK' ){

alert('The Elite Id has been assigned');
window.location.reload();
}

 

else{
alert('Error: ' + callback);
}}

Hey , 

 

I am new to salesforce triggers. I have a look up field on LEAD object called Elite_Partner_Id_gen__c . This is a lookup field to custom object called Elite_Partner_Id__c. I want the value of custom field ( Elite_Id__c) on elite_partner_Id__c object to to get copied to this look up field. Below is the code prepared from various resources. It is not showing any error but it is also not updating the look up field. Any little help will be highly appreciated.

 

trigger updateelitepartnerid on Elite_Partner_Id__c (before insert)
{
List<ID> LeadIds = New List<ID>();

for(Elite_Partner_Id__c partid : Trigger.new)
{
if(partid.Elite_Id__c != null)
{
LeadIds.add(partid.Elite_Id__c);
}
}

 

Map<Id, Lead> leadMap = new Map<Id, Lead>([SELECT Id, Elite_Partner_Id_Gen__c FROM Lead WHERE Id IN :LeadIds]);

 

for(Elite_Partner_Id__c partid : Trigger.new)
{
if(partid.Name != null)
{
Lead Ld = leadMap.get(partId.Elite_Id__c);

Ld.Elite_Partner_Id_Gen__c= partid.Elite_Id__c;

leadMap.put(partId.Elite_Id__c, Ld);
}
}

update leadMap.values();
}

On a lead record , I have created custom button (ASSIGN) which creates new record in different object ( Partner Id) . There is auto generated field in partner ID object calle NAME (standard field) . I want as soon as user clicks on ASSIGN and new record is created , it should copy that NAME value  in XL_Partner_Id__c on lead object.. I am not sure if this functionality can be achieved bu writing javascript custom button . Therefore , I am trying with trigger. it is giving me error :

Variable does not exist: partid.Name

 

trigger updateelitepartnerid on Partner_Id__c (before insert, before update){

List<ID> LeadIds = New List<ID>();

for(Partner_Id__c partid : Trigger.new){
if(partid.Name != null){
LeadIds.add(partid.Lead);
}
}

List<Lead> leadlist = [SELECT id,  XL_Partner_Id__c FROM Lead WHERE id in :LeadIds];
for(integer i = 0 ; i < leadlist.size(); i++){
leadlist[i].XL_Partner_Id__c= partid.Name ;

}

update leadlist;
}

Hey All , 

 

I apologize for posting this post again as this  issue is still bothering me. Kindly help me with the below problem .

 

So , I have these 3 fields :- 1.) Primary distrubutor( picklist and controlling field)

                                                  2.) Primary distriibutor systemID (18 digit ID,  Picklist , controlled by Primary Distributor )

                                                  3.) Preferred Distributor .....( look up field to accounts and equals to primary distri. systemID)

 

In the Web to lead form , Users can select the Primary distributor . But when I go back to check the SFDC there are no value update in Primary distriibutor systemID & Preferred Distributor. Below is the code.This code just works perfectly when I am entering the lead through SFDC . 

 

trigger LeadTrigger on Lead (before insert , before update) {
if(trigger.isBefore) {
    if(trigger.isInsert || trigger.IsUpdate) {
      for(Lead l : trigger.new) {
        if(l.primary_sysid__c != null) {
          l.preferred_distributor__c = l.primary_sysid__c;
        }
      }
    }
  }
}

Hey All , 

 

I have Trigger on Lead which is updating look up field . Its working fine when I create a lead through SFDC . But , when I use web to lead form to enter lead , Trigger is not updating look up field. Any suggestions what could be the reason ??

 

Regards

Hi All , 

 

I have two objects , leads and Accounts . Lead has three fields , distributor__c , systemid__c and pref_distributor__c . 

 

pref_distributor__c is a look up field on Accounts .    Distributor__c and systemid__c are both pick lists. Systemid__c is a dependent picklist and it's value depends on the Distributor__c . whenever I select value in distributor__c , I get a 18 digit ID in systemid__c. Now I want to write trigger which can populate the pref_distributor__c  (look up field) . We are doing this since pref_distributor__c is a look up field to accounts . It will be easy to identify the lead in account and vice versa.

 

With the help of previous posts and moderators( vinit) , I am able to write trigger and it is working fine . But , I am still newbie to unit tests Can somebody help me in writing unit test for the below mentioned trigger ?

 

trigger distyupdate on Lead (before insert , before update){
List<String> Accountname = new List<String>();
for (Lead l:Trigger.new)
{
Accountname.add(l.Distributor__c);
}
//List <Account> IDList = [Select Id from Account where Name in :Accountname];
Map<Id,Account> accMap =new Map<Id,Account> ([Select Id from Account where Name in :Accountname]);
for(Lead le:Trigger.new){
if(le.systemid__c!=null){
le.pref_distributor__c= accMap.get(le.systemid__c).Id;
}
}
}

Hi All , 

 

I have two objects , leads and Accounts . Lead has three fields , distributor__c , systemid__c and pref_distributor__c . 

 

pref_distributor__c is a look up field on Accounts .    Distributor__c and systemid__c are both pick lists. Systemid__c is a dependent picklist and it's value depends on the Distributor__c . whenever I select value in distributor__c , I get a 18 digit ID in systemid__c. Now I want to write trigger which can populate the pref_distributor__c  (look up field) . We are doing this since pref_distributor__c is a look up field to accounts . It will be easy to identify the lead in account and vice versa.

 

I have taken help from some previous posts and wrote trigger . But when I insert data into record or update it , I am getting this error.

 

Apex trigger distyupdate caused an unexpected exception, contact your administrator: distyupdate: execution of BeforeUpdate caused by: System.ListException: List index out of bounds: 0: Trigger.distyupdate: line 12, column 1

 


I have posted my code below . Kindly help me in fixing the bugs . Any little help will be highly appreciated.

 

Regards

 

 

trigger distyupdate on Lead (before insert , before update){
List<String> Accountname = new List<String>();
for (Lead l:Trigger.new)
{
Accountname.add(l.systemid__c);
}
List <Account> IDList = [Select Id from Account where Name in :Accountname];
for (Integer i = 0; i < Trigger.new.size(); i++)
{
if (Trigger.new[i].systemid__c!= null)
{
Trigger.new[i].pref_distributor__c = IDList[i].ID;
}
else
{
Trigger.new[i].pref_distributor__c= null;
}
}
}

Hi All , 

 

I have two objects , leads and Accounts . Lead has three fields , distributor__c , systemid__c and pref_distributor__c . 

 

pref_distributor__c is a look up field on Accounts .distributor__c and systemid__c are both pick lists. Systemid__c is a dependent picklist and it's value depends on the 

Hey All , 

 

I am stuck with this situation.I am lead objects in which I have two fields supplier_ID_c and Prefferd_supplier_c. The latter field has look up relation with accounts.So I first need to convert supplier_ID__c field to text format and then populates that text into Preffered_supplier__c field. I have to write trigger for this . I am fairly new to this development. Can anyone help me in writing the triiger ? Any little help will be highly appreciated

Hi All , 

 

This is the second time , I am posting this issue . But No one has been able to provide any concrete solution. Please help,

 

I have created a custom with javascript functionality and its working fine . I want when the same button is pressed twice or thrice  it should give alert message " Invalid action". I tried  using lot of things but its not working. I know it looks very easy but pls help me out in this issue. TBelow is the script:-

 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

 

var leadstatus = '{!Lead.Status}';
if (leadstatus != "Z-Program Approved")
{
alert('An Elite name cannot be assigned unless the Lead Status is equal Z-Program Approved');
}

else{

// Now calling the webservice to create a new Id 
var callback = "" + sforce.apex.execute("CreateliteId","createlite", {LeadId:"{!Lead.Id}"});

// If create and update was ok - just reload Lead page to see the id of the elite partner
if(callback == 'OK' ){

alert('The Elite Id has been assigned');
window.location.reload();
}

 

else{
alert('Error: ' + callback);
}}

Hi All , 

 

I have created a custom with javascript functionality and its working fine . I want when the same button is pressed twice or thrice  it should give alert message " Invalid action". I tried  using lot of things but its not working. I know it looks very easy but pls help me out in this issue. Below is the script:-

 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

 

var leadstatus = '{!Lead.Status}';
if (leadstatus != "Z-Program Approved")
{
alert('An Elite Id cannot be assigned unless the Lead Status is equal Z-Program Approved');
}

else{

// Now calling the webservice to create a new Id 
var callback = "" + sforce.apex.execute("CreateliteId","createlite", {LeadId:"{!Lead.Id}"});

// If create and update was ok - just reload Lead page to see the id of the elite partner
if(callback == 'OK' ){

alert('The Elite Id has been assigned');
window.location.reload();
}

 

else{
alert('Error: ' + callback);
}}

Hey , 

 

I am new to salesforce triggers. I have a look up field on LEAD object called Elite_Partner_Id_gen__c . This is a lookup field to custom object called Elite_Partner_Id__c. I want the value of custom field ( Elite_Id__c) on elite_partner_Id__c object to to get copied to this look up field. Below is the code prepared from various resources. It is not showing any error but it is also not updating the look up field. Any little help will be highly appreciated.

 

trigger updateelitepartnerid on Elite_Partner_Id__c (before insert)
{
List<ID> LeadIds = New List<ID>();

for(Elite_Partner_Id__c partid : Trigger.new)
{
if(partid.Elite_Id__c != null)
{
LeadIds.add(partid.Elite_Id__c);
}
}

 

Map<Id, Lead> leadMap = new Map<Id, Lead>([SELECT Id, Elite_Partner_Id_Gen__c FROM Lead WHERE Id IN :LeadIds]);

 

for(Elite_Partner_Id__c partid : Trigger.new)
{
if(partid.Name != null)
{
Lead Ld = leadMap.get(partId.Elite_Id__c);

Ld.Elite_Partner_Id_Gen__c= partid.Elite_Id__c;

leadMap.put(partId.Elite_Id__c, Ld);
}
}

update leadMap.values();
}

On a lead record , I have created custom button (ASSIGN) which creates new record in different object ( Partner Id) . There is auto generated field in partner ID object calle NAME (standard field) . I want as soon as user clicks on ASSIGN and new record is created , it should copy that NAME value  in XL_Partner_Id__c on lead object.. I am not sure if this functionality can be achieved bu writing javascript custom button . Therefore , I am trying with trigger. it is giving me error :

Variable does not exist: partid.Name

 

trigger updateelitepartnerid on Partner_Id__c (before insert, before update){

List<ID> LeadIds = New List<ID>();

for(Partner_Id__c partid : Trigger.new){
if(partid.Name != null){
LeadIds.add(partid.Lead);
}
}

List<Lead> leadlist = [SELECT id,  XL_Partner_Id__c FROM Lead WHERE id in :LeadIds];
for(integer i = 0 ; i < leadlist.size(); i++){
leadlist[i].XL_Partner_Id__c= partid.Name ;

}

update leadlist;
}