• Antonio_hotelbeds
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 20
    Replies

Hi all,

 

I have created a custom button that will map the fields from the lead to my custom object Groups. The problem is that the multipicklist field are not being copied. This is the code in JavaScript:

 

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

var updateRecords = []; //array for holding records that this code will ultimately update

var Grupo = new sforce.SObject("Group__c");
Grupo.Agent__c="{!Lead.Agent__c}";
Grupo.Name="{!Lead.Group_enquiry_number__c}";
Grupo.Group_Source_Market__c="{!Lead.Group_Source_Market__c}";
Grupo.Type_of_Group__c="{!Lead.Type_of_Group__c}";
Grupo.Country_Groups__c="{!Lead.Country_Groups__c}";
Grupo.Destination_Groups__c="{!Lead.Destination_Groups__c}";
Grupo.Region_Groups__c="{!Lead.Region_Groups__c}";
Grupo.Alternative_Destinations__c="{!Lead.Alternative_Destinations__c}";

Grupo.Number_of_Nights__c="{!Lead.Number_of_Nights__c}";
Grupo.Expected_Budget__c="{!Lead.Expected_Budget__c}";
Grupo.Name_of_Hotel__c="{!Lead.Name_of_otel__c}";
Grupo.Type_of_Accommodation__c="{!Lead.Type_of_Accomodation__c}";
Grupo.Category__c="{!Lead.Category__c}";
Grupo.Board_Type__c="{!Lead.Board_Type__c}";

 

//Query to get the account that group will be related to
var cliente= sforce.connection.query("Select Id from Account where AccountNumber='{!Lead.Atlas_Number__c}' and Atlas_Branch_Number__c={!Lead.Branch__c} limit 1");
records = cliente.getArray("records");
for (var i=0; i<records.length; i++) {
var record = records[i];
Grupo.Account_Name__c=record.Id;
}

 

var result = sforce.connection.create([Grupo]);

window.location.reload();

 

 

For example, the field Board_Type__c in the lead and in the group object is a multipicklist, and the content of it doesnt map between the lead and the group object.

 

Does anyone know the reason and a solution?

 

thanks,

 

Antonio

Hi all,

 

I have created a custom button that will map the fields from the lead to my custom object Groups. The problem is that the multipicklist field are not being copied. This is the code in JavaScript&colon;

 

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

var updateRecords = []; //array for holding records that this code will ultimately update

var Grupo = new sforce.SObject("Group__c");
Grupo.Agent__c="{!Lead.Agent__c}";
Grupo.Name="{!Lead.Group_enquiry_number__c}";
Grupo.Group_Source_Market__c="{!Lead.Group_Source_Market__c}";
Grupo.Type_of_Group__c="{!Lead.Type_of_Group__c}";
Grupo.Country_Groups__c="{!Lead.Country_Groups__c}";
Grupo.Destination_Groups__c="{!Lead.Destination_Groups__c}";
Grupo.Region_Groups__c="{!Lead.Region_Groups__c}";
Grupo.Alternative_Destinations__c="{!Lead.Alternative_Destinations__c}";

Grupo.Number_of_Nights__c="{!Lead.Number_of_Nights__c}";
Grupo.Expected_Budget__c="{!Lead.Expected_Budget__c}";
Grupo.Name_of_Hotel__c="{!Lead.Name_of_otel__c}";
Grupo.Type_of_Accommodation__c="{!Lead.Type_of_Accomodation__c}";
Grupo.Category__c="{!Lead.Category__c}";
Grupo.Board_Type__c="{!Lead.Board_Type__c}";

 

//Query to get the account that group will be related to
var cliente= sforce.connection.query("Select Id from Account where AccountNumber='{!Lead.Atlas_Number__c}' and Atlas_Branch_Number__c={!Lead.Branch__c} limit 1");
records = cliente.getArray("records");
for (var i=0; i<records.length; i++) {
var record = records[i];
Grupo.Account_Name__c=record.Id;
}

 

var result = sforce.connection.create([Grupo]);

window.location.reload();

 

 

For example, the field Board_Type__c in the lead and in the group object is a multipicklist, and the content of it doesnt map between the lead and the group object.

 

Does anyone know the reason and a solution?

 

thanks,

 

Antonio

Hi all,

 

we are using the web to lead functionallity in our org to configure groups.

 

Our clients introduce the information about a group in the web and we get this info as a lead. I want to convert these lead into a custom object Groups.

 

I think the best for me would be to create a new button "convert lead into group" using APEX o AJAX but I dont know where to start from. I was reading in this board but I didnt find anything clear.

 

Could you please explain me how to start?

 

Thanks,

 

Antonio

Hi,

In my org we have come to a point where our data storage is collapsed by the email messages. They take the 74% of the total of our memory on our memory isin 102% at the moment.

I was wondering if any of you had to face this situation before... All the email messages are created because of the email to case functionallity, that my support team is using at the moment. I have email messages since 2007 and we were thinking about deleting the messages created before 2010.

The thing is that I would like to make those messages available somehow to the support team, either inside Salesforce or outside (rather outside to release the data storage).

Does any of you have any solution for these situation?

Thanks a lot,

Antonio

Hi,

 

I have a problem. The kind of field created should be aligned with Salesforce. Particullary I would like to be able of creating multi pick list field.

 

In my case, when I want to calculate a quotation to my client, I would like him to choose the categories of hotel he would like: 2 stars, 3 stars, 4 stars,....

 

Also if the hotel has swimming pool, gym, Internet,...

 

With the current model I cant give the user this possibility. Do you have any ideas on how can I do this?

 

Thanks

Hi,

 

Could you please tell me if its possible to create a site where I can put a flow (created with the flow designer) that will ask about some specific information to the client through the site and flow and then create an opportunity out of it?

 

Thanks

Hi,

 

Could you please tell me if its possible to create a site where I can put a flow (created with the flow designer) that will ask about some specific information to the client through the site and flow and then create an opportunity out of it?

 

Thanks

Hi all,

At the moment we deal with groups in my company. We work in the tourism market.

We have a web page where our clients (already in Salesforce and identified by an Atlas code) introduce the information of the group as: number of people, country, destination, number of rooms, caracteristics about the accommodation,....

I would like to know if its possible to bring this information into Salesforce as an opportunity for then, our SM create a quotation.

Do you know if there is something as Web to Opportunity available or how to get it?

Thanks,

Antonio

Hi,

 

I have to develop different account interface depending on different conditions, for example depending on the record type and the user profile.

 

I am thinking about doing it in the same visualforce page using using rendered sections. Is there any other better way to do it?

 

Thanks

Hi all,

 

I have a section in my account visualforce page called Credit Info that should be shown only if the field Account Status equals "Credit". This field is also in the account object.

 

Otherwise it shouldnt be shown.

 

Could you tell me if this is possible and anyplace where I could find help to solve this issue?

 

Thanks,

 

Antonio

Hi all,

 

I am starting to create a visualforce page to create a tabbed account page and this is my code for the style and the relevant code for the visualforce page:

 

<apex:page standardController="Account" showHeader="true" tabStyle="Account" standardStyleSheets="false">
	
	<!-- Defino estilos para los tabs del segundo Panel -->
	<style>
              .activeTab2 {color:black; background-image:{!$Resource.TabAmarilloDifuminadoActiva}}
              .inactiveTab2 {background-color: #F2F5A9; color:black; background-image:none}
         </style>

<apex:tabPanel switchType="client" selectedTab="tabdetails" id="AccountExtraTabPanel" tabClass="activeTab2"
	inactiveTabClass="inactiveTab2">
		
		<apex:tab label="Administrative/Finance" name="AdministrativeInfo" id="AdministrativeInfo">
		</apex:tab>		
		
		<apex:tab label="Commercial" name="CommercialInfo" id="commercialInfo">label for commercial
		</apex:tab>
		
		<apex:tab label="Operational" name="OperationalInfo" id="OperationalInfo">
		</apex:tab>
		
		<apex:tab label="Technical" name="TechnicalInfo" id="TechnicalInfo">
		</apex:tab>
		
		<apex:tab label="Product Profile" name="ProductInfo" id="ProductInfo">
		</apex:tab>
		
		<apex:tab label="Destinos" name="DestinosInfo" id="DestinosInfo">
		</apex:tab>
	
	</apex:tabPanel>
	
</apex:page>

 

Because in the standard tab panel options, in the tabs salesforce degradates the colour from green to grey. I want to do the same but from yellow to grey in the tabs of my panel. So i created an image, called TabAmarilloDifuminadoActiva but I still see it with the green Salesfroce defatul image.

 

Could you please help me for my image to be loaded in the active tab?

 

Thanks a lot!

 





Hi,

 

I have my accounts related on a way that one parent Account is pointed by its daughters with the field ParentId.

 

I need to do a trigger that when the parent account is modified in the field Recovery_actions__C(is a checkfield), this change has to go to the daughters accounts.

 

This is my trigger:

 

trigger UpdateCierrePorRecobro on Account (beforeupdate) {

 

Set<Id> addAccountsActivate = newSet<Id>();

Set<Id> addAccountsDeactivate = newSet<Id>();

 

//Aislo los id's

 

for(integer i=0;i<Trigger.new.size();i++){

//If the value has changed add to the list

if ((Trigger.new[i].Recovery_Actions__c!=Trigger.old[i].Recovery_Actions__c)) { 

if (trigger.new[i].recovery_actions__c){//changed to true

addAccountsActivate.add(Trigger.new[i].id);

}

else{//changed to false

addAccountsDeactivate.add(Trigger.new[i].id);

}

}

}

if(addAccountsActivate.size()>0){

 

//create a list of ids with the daughter ids of the main account

//????????????????????????????????????????

List<id> listaToTrue=newList<id>();

listaParaActivar.add([select id fromAccountwhereParentId in:addAccountsActivate]);

//????????????????????????????????????????????

 

Accountacc;

 

//and update the value

for(integer j=0;j<listaToTrue.size();j++){

acc.id=listaParaActivar[j];

acc.Reacovery_Actions__c=1;

updateacc;

}

}

 

}

 

 

---------------------------------------

 

I have the problem in the part where I query in order to get the ids of the daughter accounts, I dont know how to get that list of ids.

 

Anyone could help here?

 

Thanks,

Antonio

Hi!

 

Im new in capturing errors and showing errors within salesforce and....I am a bit lost....

 

I have a trigger that is fired when converting a lead into account. This trigger will update one field of the account.

 

The problem is that in our organization we only let the sales managers convert into exisiting accounts, not into new ones. But some of them still try to convert into new ones and then, because of the trigger they get this error:

Error: UpdateNumbercontactsWhenConverting: execution of AfterUpdate caused by: System.FinalException: SObject row does not allow errors Trigger.UpdateNumbercontactsWhenConverting: line 14, column 4
 
I would like to show them a different error, easier to understand, like: ERROR:you cannot convert a lead into a new account.
 
Any ideas on how to do it?This is my code. I tried with the addError but i get

Save error: Method does not exist or incorrect signature: addError(String)

 

trigger UpdateNumbercontactsWhenConverting onLead (afterupdate) {

 

Set<Id> addAccounts = newSet<Id>();

 

for (Lead lead: Trigger.new){

 

if(lead.IsConverted){

addAccounts.add(lead.ConvertedAccountId);

}

}

if

(addAccounts.size()>0){

Map<Id,

Account> Updatevalue = new Map<Id,Account>([select Number_contacts__c fromAccountwhereId in: addAccounts]);

 

for (Accountacc:Updatevalue.values()){

 

if (acc.Number_contacts__c==NULL) {

addError(

'You cannot convert a lead into a new account only into an existing one');

}

acc.Number_contacts__c=acc.Number_contacts__c+1;

}

updateUpdatevalue.values();

}

}

 

Thanks!!

 

BTW, I am in the conversion screen and I would like to show the error in that screen.

Hi!

 

Im new in capturing errors and showing errors within salesforce and....I am a bit lost....

 

I have a trigger that is fired when converting a lead into account. This trigger will update one field of the account.

 

The problem is that in our organization we only let the sales managers convert into exisiting accounts, not into new ones. But some of them still try to convert into new ones and then, because of the trigger they get this error:

Error: UpdateNumbercontactsWhenConverting: execution of AfterUpdate caused by: System.FinalException: SObject row does not allow errors Trigger.UpdateNumbercontactsWhenConverting: line 14, column 4
 
I would like to show them a different error, easier to understand, like: ERROR:you cannot convert a lead into a new account.
 
Any ideas on how to do it?This is my code. I tried with the addError but i get

Save error: Method does not exist or incorrect signature: addError(String)

 

trigger UpdateNumbercontactsWhenConverting onLead (afterupdate) {

 

Set<Id> addAccounts = newSet<Id>();

 

for (Lead lead: Trigger.new){

 

if(lead.IsConverted){

addAccounts.add(lead.ConvertedAccountId);

}

}

if

(addAccounts.size()>0){

Map<Id,

Account> Updatevalue = new Map<Id,Account>([select Number_contacts__c fromAccountwhereId in: addAccounts]);

 

for (Accountacc:Updatevalue.values()){

 

if (acc.Number_contacts__c==NULL) {

addError(

'You cannot convert a lead into a new account only into an existing one');

}

acc.Number_contacts__c=acc.Number_contacts__c+1;

}

updateUpdatevalue.values();

}

}

 

Thanks!!

Hi,

 

I just programmed a bulk trigger(or tried to, because Im starting with bulk triggers) in leads that update info in leads depending on the record type and the country of the lead. The problem is that if I change the country of the lead and click on Save, the data doest get updated until I click on Edit and Save again.Isnt that weird? Does anyone know why is that?

 

Here is my trigger code:

 

trigger UpdateMerchantInterface onLead (beforeinsert,beforeupdate) {

 

Set<Id> addLeads = newSet<Id>();

 

for (Lead lead: Trigger.new){

 

if (lead.RecordTypeId=='01220000000YDkG'){

addLeads.add(lead.id);

}

elseif (lead.RecordTypeId=='012D00000002iGo' && lead.Route_to_market_del__c=='HOTELBEDS'){

addLeads.add(lead.id);

}

elseif (lead.RecordTypeId=='012D00000002iGo' && lead.Route_to_market_del__c=='BEDSONLINE'){

addLeads.add(lead.id);

}

elseif (lead.RecordTypeId=='012D00000002iGo' && lead.Route_to_market_del__c=='HOTELOPIA'){

addLeads.add(lead.id);

}

}

if(addLeads.size()>0){

               Map<Id,Lead> Updatevalues1 = new Map<Id,Lead> ([select route_to_market_del__c,RecordTypeId,Area__c,Lead_Country__c,Merchant__c,Interface__c,Invoicing_Company_Empresas__c from Lead where Id in: addLeads]);

 

     for (Lead ld2:Updatevalues1.values()){

 

               if (ld2.RecordTypeId=='012D00000002iGo' && ld2.Route_to_market_del__c=='HOTELBEDS'){//Caso de HB

                     if (ld2.Lead_Country__c=='SPAIN'){

                              ld2.Interface__c='WL';

                                        ld2.Invoicing_Company_Empresas__c='EW1';

                                        ld2.Merchant__c='WHITELABLEEUR';

                               }

               }

        }

     for (Lead l: Trigger.new){

       l.Interface__c=Updatevalues1.get(l.id).Interface__c ;

       l.Merchant__c=Updatevalues1.get(l.id).Merchant__c;

       l.Invoicing_Company_Empresas__c=Updatevalues1.get(l.id).Invoicing_Company_Empresas__c;

}

//}

}

 

I dont know why is this happening.

 

Thanks!

 

}


Hi!!

I have created a button that when the user clicks on it the value of a checkbox field is changed to true.

 

I created a checkbox field in the credit request called IsEmailSend.When the user click the button "send contact information"

I wrote a code that automatically changes this checkbox to true and then a workflow is fired and sends an email.

 

I have a problem with the code of the button. This is de code:

 

{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")}

var update_CR = []; /*Declaring an array to pass the parameters */
var CR= new sforce.SObject("Credit_Request__c"); /* Declaring an object for the Credit request */
CR.Id='{!Credit_Request__c.Id}'; /*setting the ID of the object to the Id of the current credit request*/
CR.is_Email_Send__c = true; /* Setting the checkbox value as true */
update_CR.push(CR); /*pushing the updated object in queue*/
result_Update=sforce.connection.update(update_CR); /*updating the object*/
window.location.reload(); /* asking the page to refresh */

 

 

This button only updates the field IsEmailSend when Im logged as administrator, not when I am logged as any of my Sales Managers.

Could anyone help please?

 

Thanks!

Hi there,

I need to retrieve the tasks related to an account having the account id.

I am developing a trigger that, when an activity is deleted has to check if there is any other activity for that account in order to update the field "Evolution stage". If the last activity is deleted the evolution stage must go back to "Agency to be contacted".Here is my code:

trigger TaskSumTrigger on Task (after insert,after update,after delete,after undelete) {

    if (Trigger.isDelete){
           List<Task> tasks = new list<task>();
            tasks= Trigger.old;   
            if (tasks.size()== 1){
               List<ID> acctIds = new List<ID>();
                for (Task tk : tasks) {
                    acctIds.add(tk.AccountId);
                }  
               Account account =new Account(Id=acctIds.get(0));

             //HERE I NEED TO CHECK IF IT HAS MORE ACTIVITIES TO DO THE FOLLOWING OR NOT
            task[] rest=[select id from task where AccountId ????????]
            if (rest.size()==0){//IF THERE ARE NO MORE ACTIVITIES DO THE FOLLOWING

                if (account.Evolution_Stage__c=='4 - Bookings done'){
                   No hacer nada    
                }else if (account.Access_codes_sent__c==NULL){
                    account.Evolution_Stage__c='1 - Agency to be contacted';
                    update account;
                }else{
                 /  account.Evolution_Stage__c='2 - Access codes created';
                   update account;
               }
             }           
             }
    }
    else{
    Task[] tasks;

        tasks= Trigger.new;
       
    // creo un conjunto set de ID   
    List<ID> acctIds = new List<ID>();  
    //cargo este set con los id de las cuentas de los eventos  
    for (Task tk : tasks) {
        if ((tk.Status=='Completed') & (tk.BOL_Level_III_Result__c!='')){
            acctIds.add(tk.AccountId);
        }
    }   //ahora acctIds es una lista sin repeticiones de identificadores de cuentas
   
    //Actualizar los evolution stage de las cuentas si cumplen las condiciones
    for(Integer i=0; i< acctIds.size();i++){
        Account account =new Account(Id=acctIds.get(i));
        if (account.Evolution_Stage__c!='4 - Bookings done'){
            account.Evolution_Stage__c='3 - Agency Contacted (Visit / Call)';
            update account;
        }
    }
    }

}

I got completely stucked in the part where I want to check if there is any other activity related to the account. could you please help me?Any ideas??

Thanks a lot for your help!!

Hi all,

 

we are using the web to lead functionallity in our org to configure groups.

 

Our clients introduce the information about a group in the web and we get this info as a lead. I want to convert these lead into a custom object Groups.

 

I think the best for me would be to create a new button "convert lead into group" using APEX o AJAX but I dont know where to start from. I was reading in this board but I didnt find anything clear.

 

Could you please explain me how to start?

 

Thanks,

 

Antonio

Hi all,

At the moment we deal with groups in my company. We work in the tourism market.

We have a web page where our clients (already in Salesforce and identified by an Atlas code) introduce the information of the group as: number of people, country, destination, number of rooms, caracteristics about the accommodation,....

I would like to know if its possible to bring this information into Salesforce as an opportunity for then, our SM create a quotation.

Do you know if there is something as Web to Opportunity available or how to get it?

Thanks,

Antonio

Hi all,

 

I have a section in my account visualforce page called Credit Info that should be shown only if the field Account Status equals "Credit". This field is also in the account object.

 

Otherwise it shouldnt be shown.

 

Could you tell me if this is possible and anyplace where I could find help to solve this issue?

 

Thanks,

 

Antonio

Hi all,

 

I am starting to create a visualforce page to create a tabbed account page and this is my code for the style and the relevant code for the visualforce page:

 

<apex:page standardController="Account" showHeader="true" tabStyle="Account" standardStyleSheets="false">
	
	<!-- Defino estilos para los tabs del segundo Panel -->
	<style>
              .activeTab2 {color:black; background-image:{!$Resource.TabAmarilloDifuminadoActiva}}
              .inactiveTab2 {background-color: #F2F5A9; color:black; background-image:none}
         </style>

<apex:tabPanel switchType="client" selectedTab="tabdetails" id="AccountExtraTabPanel" tabClass="activeTab2"
	inactiveTabClass="inactiveTab2">
		
		<apex:tab label="Administrative/Finance" name="AdministrativeInfo" id="AdministrativeInfo">
		</apex:tab>		
		
		<apex:tab label="Commercial" name="CommercialInfo" id="commercialInfo">label for commercial
		</apex:tab>
		
		<apex:tab label="Operational" name="OperationalInfo" id="OperationalInfo">
		</apex:tab>
		
		<apex:tab label="Technical" name="TechnicalInfo" id="TechnicalInfo">
		</apex:tab>
		
		<apex:tab label="Product Profile" name="ProductInfo" id="ProductInfo">
		</apex:tab>
		
		<apex:tab label="Destinos" name="DestinosInfo" id="DestinosInfo">
		</apex:tab>
	
	</apex:tabPanel>
	
</apex:page>

 

Because in the standard tab panel options, in the tabs salesforce degradates the colour from green to grey. I want to do the same but from yellow to grey in the tabs of my panel. So i created an image, called TabAmarilloDifuminadoActiva but I still see it with the green Salesfroce defatul image.

 

Could you please help me for my image to be loaded in the active tab?

 

Thanks a lot!

 





Hi,

 

I have my accounts related on a way that one parent Account is pointed by its daughters with the field ParentId.

 

I need to do a trigger that when the parent account is modified in the field Recovery_actions__C(is a checkfield), this change has to go to the daughters accounts.

 

This is my trigger:

 

trigger UpdateCierrePorRecobro on Account (beforeupdate) {

 

Set<Id> addAccountsActivate = newSet<Id>();

Set<Id> addAccountsDeactivate = newSet<Id>();

 

//Aislo los id's

 

for(integer i=0;i<Trigger.new.size();i++){

//If the value has changed add to the list

if ((Trigger.new[i].Recovery_Actions__c!=Trigger.old[i].Recovery_Actions__c)) { 

if (trigger.new[i].recovery_actions__c){//changed to true

addAccountsActivate.add(Trigger.new[i].id);

}

else{//changed to false

addAccountsDeactivate.add(Trigger.new[i].id);

}

}

}

if(addAccountsActivate.size()>0){

 

//create a list of ids with the daughter ids of the main account

//????????????????????????????????????????

List<id> listaToTrue=newList<id>();

listaParaActivar.add([select id fromAccountwhereParentId in:addAccountsActivate]);

//????????????????????????????????????????????

 

Accountacc;

 

//and update the value

for(integer j=0;j<listaToTrue.size();j++){

acc.id=listaParaActivar[j];

acc.Reacovery_Actions__c=1;

updateacc;

}

}

 

}

 

 

---------------------------------------

 

I have the problem in the part where I query in order to get the ids of the daughter accounts, I dont know how to get that list of ids.

 

Anyone could help here?

 

Thanks,

Antonio

Hi!

 

Im new in capturing errors and showing errors within salesforce and....I am a bit lost....

 

I have a trigger that is fired when converting a lead into account. This trigger will update one field of the account.

 

The problem is that in our organization we only let the sales managers convert into exisiting accounts, not into new ones. But some of them still try to convert into new ones and then, because of the trigger they get this error:

Error: UpdateNumbercontactsWhenConverting: execution of AfterUpdate caused by: System.FinalException: SObject row does not allow errors Trigger.UpdateNumbercontactsWhenConverting: line 14, column 4
 
I would like to show them a different error, easier to understand, like: ERROR:you cannot convert a lead into a new account.
 
Any ideas on how to do it?This is my code. I tried with the addError but i get

Save error: Method does not exist or incorrect signature: addError(String)

 

trigger UpdateNumbercontactsWhenConverting onLead (afterupdate) {

 

Set<Id> addAccounts = newSet<Id>();

 

for (Lead lead: Trigger.new){

 

if(lead.IsConverted){

addAccounts.add(lead.ConvertedAccountId);

}

}

if

(addAccounts.size()>0){

Map<Id,

Account> Updatevalue = new Map<Id,Account>([select Number_contacts__c fromAccountwhereId in: addAccounts]);

 

for (Accountacc:Updatevalue.values()){

 

if (acc.Number_contacts__c==NULL) {

addError(

'You cannot convert a lead into a new account only into an existing one');

}

acc.Number_contacts__c=acc.Number_contacts__c+1;

}

updateUpdatevalue.values();

}

}

 

Thanks!!

 

BTW, I am in the conversion screen and I would like to show the error in that screen.

Hi!

 

Im new in capturing errors and showing errors within salesforce and....I am a bit lost....

 

I have a trigger that is fired when converting a lead into account. This trigger will update one field of the account.

 

The problem is that in our organization we only let the sales managers convert into exisiting accounts, not into new ones. But some of them still try to convert into new ones and then, because of the trigger they get this error:

Error: UpdateNumbercontactsWhenConverting: execution of AfterUpdate caused by: System.FinalException: SObject row does not allow errors Trigger.UpdateNumbercontactsWhenConverting: line 14, column 4
 
I would like to show them a different error, easier to understand, like: ERROR:you cannot convert a lead into a new account.
 
Any ideas on how to do it?This is my code. I tried with the addError but i get

Save error: Method does not exist or incorrect signature: addError(String)

 

trigger UpdateNumbercontactsWhenConverting onLead (afterupdate) {

 

Set<Id> addAccounts = newSet<Id>();

 

for (Lead lead: Trigger.new){

 

if(lead.IsConverted){

addAccounts.add(lead.ConvertedAccountId);

}

}

if

(addAccounts.size()>0){

Map<Id,

Account> Updatevalue = new Map<Id,Account>([select Number_contacts__c fromAccountwhereId in: addAccounts]);

 

for (Accountacc:Updatevalue.values()){

 

if (acc.Number_contacts__c==NULL) {

addError(

'You cannot convert a lead into a new account only into an existing one');

}

acc.Number_contacts__c=acc.Number_contacts__c+1;

}

updateUpdatevalue.values();

}

}

 

Thanks!!

Hi,

 

I just programmed a bulk trigger(or tried to, because Im starting with bulk triggers) in leads that update info in leads depending on the record type and the country of the lead. The problem is that if I change the country of the lead and click on Save, the data doest get updated until I click on Edit and Save again.Isnt that weird? Does anyone know why is that?

 

Here is my trigger code:

 

trigger UpdateMerchantInterface onLead (beforeinsert,beforeupdate) {

 

Set<Id> addLeads = newSet<Id>();

 

for (Lead lead: Trigger.new){

 

if (lead.RecordTypeId=='01220000000YDkG'){

addLeads.add(lead.id);

}

elseif (lead.RecordTypeId=='012D00000002iGo' && lead.Route_to_market_del__c=='HOTELBEDS'){

addLeads.add(lead.id);

}

elseif (lead.RecordTypeId=='012D00000002iGo' && lead.Route_to_market_del__c=='BEDSONLINE'){

addLeads.add(lead.id);

}

elseif (lead.RecordTypeId=='012D00000002iGo' && lead.Route_to_market_del__c=='HOTELOPIA'){

addLeads.add(lead.id);

}

}

if(addLeads.size()>0){

               Map<Id,Lead> Updatevalues1 = new Map<Id,Lead> ([select route_to_market_del__c,RecordTypeId,Area__c,Lead_Country__c,Merchant__c,Interface__c,Invoicing_Company_Empresas__c from Lead where Id in: addLeads]);

 

     for (Lead ld2:Updatevalues1.values()){

 

               if (ld2.RecordTypeId=='012D00000002iGo' && ld2.Route_to_market_del__c=='HOTELBEDS'){//Caso de HB

                     if (ld2.Lead_Country__c=='SPAIN'){

                              ld2.Interface__c='WL';

                                        ld2.Invoicing_Company_Empresas__c='EW1';

                                        ld2.Merchant__c='WHITELABLEEUR';

                               }

               }

        }

     for (Lead l: Trigger.new){

       l.Interface__c=Updatevalues1.get(l.id).Interface__c ;

       l.Merchant__c=Updatevalues1.get(l.id).Merchant__c;

       l.Invoicing_Company_Empresas__c=Updatevalues1.get(l.id).Invoicing_Company_Empresas__c;

}

//}

}

 

I dont know why is this happening.

 

Thanks!

 

}


Hi!!

I have created a button that when the user clicks on it the value of a checkbox field is changed to true.

 

I created a checkbox field in the credit request called IsEmailSend.When the user click the button "send contact information"

I wrote a code that automatically changes this checkbox to true and then a workflow is fired and sends an email.

 

I have a problem with the code of the button. This is de code:

 

{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")}

var update_CR = []; /*Declaring an array to pass the parameters */
var CR= new sforce.SObject("Credit_Request__c"); /* Declaring an object for the Credit request */
CR.Id='{!Credit_Request__c.Id}'; /*setting the ID of the object to the Id of the current credit request*/
CR.is_Email_Send__c = true; /* Setting the checkbox value as true */
update_CR.push(CR); /*pushing the updated object in queue*/
result_Update=sforce.connection.update(update_CR); /*updating the object*/
window.location.reload(); /* asking the page to refresh */

 

 

This button only updates the field IsEmailSend when Im logged as administrator, not when I am logged as any of my Sales Managers.

Could anyone help please?

 

Thanks!

Hi there,

I need to retrieve the tasks related to an account having the account id.

I am developing a trigger that, when an activity is deleted has to check if there is any other activity for that account in order to update the field "Evolution stage". If the last activity is deleted the evolution stage must go back to "Agency to be contacted".Here is my code:

trigger TaskSumTrigger on Task (after insert,after update,after delete,after undelete) {

    if (Trigger.isDelete){
           List<Task> tasks = new list<task>();
            tasks= Trigger.old;   
            if (tasks.size()== 1){
               List<ID> acctIds = new List<ID>();
                for (Task tk : tasks) {
                    acctIds.add(tk.AccountId);
                }  
               Account account =new Account(Id=acctIds.get(0));

             //HERE I NEED TO CHECK IF IT HAS MORE ACTIVITIES TO DO THE FOLLOWING OR NOT
            task[] rest=[select id from task where AccountId ????????]
            if (rest.size()==0){//IF THERE ARE NO MORE ACTIVITIES DO THE FOLLOWING

                if (account.Evolution_Stage__c=='4 - Bookings done'){
                   No hacer nada    
                }else if (account.Access_codes_sent__c==NULL){
                    account.Evolution_Stage__c='1 - Agency to be contacted';
                    update account;
                }else{
                 /  account.Evolution_Stage__c='2 - Access codes created';
                   update account;
               }
             }           
             }
    }
    else{
    Task[] tasks;

        tasks= Trigger.new;
       
    // creo un conjunto set de ID   
    List<ID> acctIds = new List<ID>();  
    //cargo este set con los id de las cuentas de los eventos  
    for (Task tk : tasks) {
        if ((tk.Status=='Completed') & (tk.BOL_Level_III_Result__c!='')){
            acctIds.add(tk.AccountId);
        }
    }   //ahora acctIds es una lista sin repeticiones de identificadores de cuentas
   
    //Actualizar los evolution stage de las cuentas si cumplen las condiciones
    for(Integer i=0; i< acctIds.size();i++){
        Account account =new Account(Id=acctIds.get(i));
        if (account.Evolution_Stage__c!='4 - Bookings done'){
            account.Evolution_Stage__c='3 - Agency Contacted (Visit / Call)';
            update account;
        }
    }
    }

}

I got completely stucked in the part where I want to check if there is any other activity related to the account. could you please help me?Any ideas??

Thanks a lot for your help!!