• Lago S.p.a.
  • NEWBIE
  • 40 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 18
    Replies
Hi, I have serios problem about this visualforce and I can't figure it out :(.
It must be published on a public site, for making a customer to update a custom object.
The visualforce runs correctly and the record is saved when modified, but on the force.com site I have this error:
core.apexpages.exceptions.ApexPagesGenericException: system.security.NoAccessException:Accesss in update denied for DealerContact__c, Controller action methods may not be executed.

Here is my visualforce controller:
<apex:page docType="html-5.0" showHeader="false" Controller="DealerContactController">
    <apex:variable value="{!contacts}" var="ct"/>
    <apex:define name="Header">
        <h3 class="slds-section-title--divider">Contact List</h3>
    </apex:define>
    <apex:slds />
    <div class= "slds-scope">
        <div class="slds-grid slds-wrap slds-align_absolute-center">
            <div class="slds-col slds-size--4-of-4 slds-small-size--1-of-4 slds-medium-size--3-of-4">
                <!-- Contacts List -->
                <apex:form id="myform">
                     <apex:messages />
                    <apex:repeat value="{!contacts}" var="ct" rendered="true">
                        <apex:pageBlock >
                            <apex:pageBlockSection >
                                <apex:inputText styleClass="slds-input slds-align_absolute-center" value="{!ct.first_name__c}" />
                                <!--<apex:inputText styleClass="slds-input slds-align_absolute-center" value="{!ct.LastName}"/> -->
                                <apex:inputText styleClass="slds-input" value="{!ct.Email__c}" />
                                <apex:selectList styleClass="slds-input" value="{!ct.Type__c}" size="1">
                                    <apex:selectOptions value="{!Items}" rendered="true" />
                                </apex:selectList>
                                 <!--<apex:pageBlockSectionItem >
                                     <apex:outputLabel value="{!$ObjectType.Contact.fields.type__c.label}" />
                                    <apex:selectList styleClass="slds-input"  value="{!options}"   size="1">
                                        <apex:selectOptions value="{!Items}" rendered="true"/>
                                    </apex:selectList> 
                                </apex:pageBlockSectionItem> -->    
                            </apex:pageBlockSection>
                        </apex:pageBlock>
                    </apex:repeat> 
                    <div class="slds-is-relative position=central">
                       <apex:commandButton styleclass="slds-align_absolute-center slds-button slds-button_brand" value="Press here to Save" action="{!save}" />
                        <input type="Button" value="submit" action="doAction()"/>
                        <apex:actionFunction name="doAction" action="{!save}" rerender="myform"/>
                    </div>
                       
                    <!--<apex:commandButton styleClass="slds-button slds-button--brand slds-button--neutral slds-not-selected" value="Cancel" action="{!cancel}"/>
<apex:commandButton styleClass="slds-button slds-button--brand slds-button--neutral slds-not-selected" value="Edit" action="{!edit}"/>                                                        
-->    
                </apex:form>
            </div>
        </div>
    </div>
</apex:page>

and its controller
//DEALERCONTACT CONTROLLER////////////////
//CLASS
public without sharing class DealerContactController {
    public DealerContact__c contact {get;set;}//new DealerContact__c();
    public List<DealerContact__c> contacts {get;set;}//new List<DealerContact__c>();
    public List<SelectOption> options {get;set;}
    public List<SelectOption> statusOptions {get;set;}
    public string defaultOption {get;set;}
    public string defaultvalue{get;set;}
    //CONSTRUCTOR
    public DealerContactController() {
        contacts = [select ID,First_Name__c ,type__c, email__c from 
                    DealerContact__c order by First_Name__c  limit 10];
        system.debug(contacts);
        statusOptions = new List <SelectOption>();
        List<Schema.Picklistentry> entries = Schema.DealerContact__c.type__c.getDescribe().getPicklistValues();
        //opt = contact.type__c;
        // For each picklist value, a new select option created
        for (Schema.Picklistentry entry: entries) {
            statusOptions.add(new SelectOption(entry.getValue(), entry.getLabel()));
            //check default value and assign
            //}
        }
    }
    //GETTER METHOD
    public List<DealerContact__c> getContacts(){
        List<DealerContact__c> result = [select ID,First_Name__c ,type__c, email__c from 
                    DealerContact__c order by First_Name__c  limit 10];
        system.debug(result);
        return result;
    }
    //SAVE METHOD #1
    public pagereference save(){
        update contacts;
        //return apexpages.currentpage();
        return null;
    }
}

Any help will be appreciated.
Thanks in advance.
Hi experts!
I have a little problem with a simple force.com site that I'm building.
I want to see a list of contacts with basic info, one of these info is a picklist field, but when I render the page, this picklist show the first value of list instead of the current value of the record.
Here's my VF Code of the picklist:
VF
<apex:pageBlockSectionItem >
                                    <apex:outputLabel value="{!$ObjectType.Contact.fields.type__c.label}" />
                                    <apex:selectList styleClass="slds-input"  value="{!statusOptions}"   size="1">
                                        <apex:selectOptions value="{!ItemsList}" rendered="true"/>
                                    </apex:selectList>
                                </apex:pageBlockSectionItem>
And the method of the controller:

public List<Selectoption> getItemsList(){
        List<SelectOption> options = new List<SelectOption>(); 
        List<Schema.Picklistentry> fieldResult = Schema.Contact.type__c.getDescribe().getPicklistValues();
        //options.add(new SelectOption());
        for(Schema.PicklistEntry f : fieldResult) {
            options.add(new SelectOption(f.getValue(), f.getLabel()));
        }
        return options;
    }

Any help will be very appreciated! Thanks in advance.
Hi everyone! I've a little problem with a visualforce template.
I'd like to add in this template various fields on account parent object, but when I test with a test contact, I don't see any field of the related account :(
Here's a part of my code:
<messaging:emailTemplate recipientType="Contact"
    relatedToType="Contact"
    subject="CONDICIONES COMERCIALES PARA EL AÑO 2020"
    replyTo="web@lago.it" 
    >
    
<messaging:htmlEmailBody >        
    <html>
        <body>
            <div>
                <img src="https://www.lago.it/wp-content/uploads/2020/02/header-mail.png" style="width:60%;margin:5% 40% 5% 0%" border="0"></img>
            </div>
            <div style="margin-left: 40%;width:60%" align="left">
                <apex:variable var="Name" value="{!relatedTo.Account.Name}" />
                {!Name}<br/>
                {!relatedTo.Account.BillingStreet},{!relatedTo.Account.BillingCity}<br/>
                {!relatedTo.Account.BillingPostalCode},{!relatedTo.Account.BillingCountry}<br/>
                <apex:outputText id="PIVA" rendered="{!IF(relatedTo.Account.piva__c <> '' , 'true', 'false')}">
                    CIF: {!relatedTo.Account.piva__c}<br/> etc etc....

Any help will be appreciated..Have a nice day :)
Hi, we have a job that runs nightly, but from sunday, when trying to connect, we receive the following error:
Fault-tolerance-login-failed : There was a communication error when talking to Salesforce.com: Transport error: 302 Error: Found
​Any help will be accepted, thanks!
Hi, we have a job that runs nightly, but from sunday, when trying to connect, we receive the following error:
Fault-tolerance-login-failed : There was a communication error when talking to Salesforce.com: Transport error: 302 Error: Found
​Any halp will be accepted, thanks!
Hi, I have a problem with my visualforce. I would like to show a particular panel if I choose a record type, initially it works, but when I try to click save button, the records of the contract are not saved and the page remains as I left it.
Here' s my visualforce code:

<apex:page StandardController="Contract">
<apex:variable value="{!Contract.Account}" var="Account"/>
<apex:variable value="{!Contract.RecordType}" var="recordtype"/>
  <h1>Contract</h1>
  <apex:define name="Header">
         <apex:sectionHeader title="{!$ObjectType.Contract.label}" subtitle="Nuovo Contratto"/>
             <apex:form >
                <apex:inlineEditSupport event="ondblClick">
                <apex:pageBlock mode="view">
                    <apex:pageBlockButtons location="both">
                        <apex:commandButton value="Save" action="{!save}"/>
                        
                        <apex:outputPanel id="ContrattoProgettazione">
                        <apex:commandButton value="Contratto Progettazione" action="{! URLFOR($Action.Contract.Contratto_Progettazione, Id)}" rendered="{!Contract.accordo_prog__c=='Si'}"/>
                        <apex:inputField value="{!Contract.RecordTypeId}"/>
                        </apex:outputPanel>
                    </apex:pageBlockButtons>
                    <apex:actionRegion >
                 <apex:outputPanel id="Contratto_Shop" rendered="{!Contract.RecordTypeId = '01230000000EeSO'}">
                    <apex:pageBlockSection id="Shop1" columns="2" title="Dettagli Contratto Shop" >
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:outputField value="{!Contract.ContractNumber}" />
                            <apex:inputField value="{!Contract.AccountId}" required="true"/>
                            <apex:inputField value="{!Contract.Tipo__c}" required="true"/>
                            <apex:outputField value="{!Contract.agente__c}"/>
                            <apex:inputField value="{!Contract.Stato__c}" required="true"/>
                            <apex:outputField value="{!Contract.customercode__c}"/> 
                            <!--<apex:inputField value="{!Contract.Status}"/>-->
                            <apex:outputField value="{!Contract.PrimoContratto__c}"/>
                            <apex:inputField value="{!Contract.SpazioEsposizione__c}" required="true"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
                    <apex:pageBlockSection id="Shop2" columns="2" title="Condizioni" >
                        <apex:inlineEditSupport event="ondblClick">
                        <apex:inputField value="{!Contract.Type__c}" required="true"/>  
                        <apex:inputField value="{!Contract.contract_sign_date__c}"/>
                        <apex:inputField value="{!Contract.discount__c}" required="true"/>
                        <apex:inputField value="{!Contract.StartDate}"/>
                        <apex:inputField value="{!Contract.ChiaviInMano__c}"/>
                        <apex:inputField value="{!Contract.endContractDate__c}"/>
                        <apex:inputField value="{!Contract.ServizioOutlet__c}"/>
                        <apex:inputField value="{!Contract.addebito_spese__c}"/>
                        <apex:inputField value="{!Contract.data_start_add_spese__c}"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
                    <apex:pageBlockSection id="Shop3" columns="2" title="Budget" >
                        <apex:inlineEditSupport event="ondblClick">
                        <apex:inputField value="{!Contract.Budget_2016__c}"/>
                        <apex:inputField value="{!Contract.target_2016__c}"/>
                        <apex:inputField value="{!Contract.Budget_2017__c}"/>
                        <apex:inputField value="{!Contract.target_2017__c}"/>
                        <apex:inputField value="{!Contract.Budget_2018__c}"/>
                        <apex:inputField value="{!Contract.bdg_rinnovo_2016__c}"/>
                        <apex:inputField value="{!Contract.budget_2019__c}"/>
                        <apex:inputField value="{!Contract.rinnovo_2017__c}"/>
                        <apex:inputField value="{!Contract.sconto_prec__c}"/>  
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
               </apex:outputPanel>
               <apex:outputPanel id="Contratto_Discover" rendered="{Contract.RecordTypeId ==‘012a0000001W9qA'}">
                    <apex:pageBlockSection id="section1" columns="2" title="Dettagli Contratto Discover" >
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:inputField value="{!Contract.AccountId}"/>
                            <apex:inputField value="{!Contract.ContractNumber}" />
                            <apex:inputField value="{!Contract.Type__c}" required="true"/>
                            <apex:inputField value="{!Contract.Tipo__c}" required="true"/> 
                            <apex:inputField value="{!Contract.agente__c}"/>
                            <apex:inputField value="{!Contract.Status}" required="true"/>
                            <apex:inputField value="{!Contract.accordo_prog__c}" required="true"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
                        
                    <apex:pageBlockSection id="section2" columns="2" title="Condizioni Commerciali">
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:outputField value="{!Contract.invio_lett_intenti__c}"/>
                            <apex:outputField value="{!Contract.ricez_lettera_intenti__c}" />
                            <apex:outputField value="{!Contract.StartDate}"/> 
                            <apex:outputField value="{!Contract.endContractDate__c}" />
                            <apex:outputField value="{!Contract.discount__c}"/>
                            <apex:outputField value="{!Contract.contract_sign_date__c}"/> 
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>  
                </apex:outputPanel>    
                    
                
                   <apex:pageBlockSection id="section4" columns="2" title="Informazioni sul sistema">
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:inputField value="{!Contract.CreatedById}"/>
                            <apex:inputField value="{!Contract.LastModifiedById}"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>  
                </apex:actionRegion>
                    
                </apex:pageBlock>
                </apex:inlineEditSupport>
             </apex:form>
  </apex:define>
</apex:page>
                   
Thank you in advance!!!
Hi, I would like to see a particular Visualforce on setting a particular record type on a Contract.
The problem is that the page gaves a loop or this message: 
"The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores". 
Here's my controller:

public with sharing class ContractDiscoverPage {

private ApexPages.StandardController controller;
public String retURL {get; set;}
public String saveNewURL {get; set;}
public String rType {get; set;}
public String cancelURL {get; set;}
public String ent {get; set;}
public String confirmationToken {get; set;}
public String accountID {get; set;}
//public String contactID {get; set;}

public ContractDiscoverPage(ApexPages.StandardController controller) {

this.controller = controller;

//retURL = ApexPages.currentPage().getParameters().get('retURL');
rType = ApexPages.currentPage().getParameters().get('RecordType');
cancelURL = ApexPages.currentPage().getParameters().get('cancelURL');
ent = ApexPages.currentPage().getParameters().get('ent');
confirmationToken = ApexPages.currentPage().getParameters().get('_CONFIRMATIONTOKEN');
saveNewURL = ApexPages.currentPage().getParameters().get('save_new_url');
accountID = ApexPages.currentPage().getParameters().get('def_account_id');
//contractID = ApexPages.currentPage().getParameters().get('def_contract_id');
}

public PageReference redirect() {

PageReference returnURL;

// Redirect if Record Type corresponds to custom VisualForce page

IF(rType == '012a0000001W9qA') {

returnURL = new PageReference('/apex/ContractDiscover/' + 'accountID' +  '?nooverride=1');

}

ELSE {

returnURL = new PageReference('/800/e');

}

returnURL.getParameters().put('retURL', retURL);
returnURL.getParameters().put('RecordType', rType);
returnURL.getParameters().put('cancelURL', cancelURL);
returnURL.getParameters().put('ent', ent);
returnURL.getParameters().put('_CONFIRMATIONTOKEN', confirmationToken);
returnURL.getParameters().put('save_new_url', saveNewURL);
returnURL.getParameters().put('nooverride', '1');
returnURL.getParameters().put('accid', accountID );
IF (accountID != null){

returnURL.getParameters().put('def_account_id', accountID);

}


returnURL.setRedirect(true);
return returnURL;

}
}

And this is my visualforce:

<apex:page standardController="Contract" extensions="ContractDiscoverPage" tabStyle="Contract" showheader="true" action="{!redirect}">
<apex:variable value="{!Contract.Account}" var="Account=Account"/>
  <h1>Contract</h1>
  <apex:define name="Header">
         <apex:sectionHeader title="{!$ObjectType.Contract.label}" subtitle="Contratto per: {'Contract.Account.Name}"/>
             <apex:form >
                <apex:inlineEditSupport event="ondblClick">
                <apex:pageBlock mode="view">
                    <apex:pageBlockButtons location="both">
                        <apex:commandButton value="Save" action="{!save}"/>
                        <apex:commandButton value="Cancel" action="{!cancel}"/>
                        <apex:commandButton action="{!delete}" value="Delete"/>
                        <apex:commandButton action="{!delete}" value="Contratto progettazione"/>
                    </apex:pageBlockButtons>
                    <apex:actionRegion >
                   
                    <apex:pageBlockSection id="section1" columns="3" title="Dettagli Contratto">
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:outputField value="{!Contract.AccountId}"/>
                            <apex:outputField value="{!Contract.ContractNumber}" />
                            <apex:inputField value="{!Contract.RecordTypeId}"/> 
                            <apex:outputField value="{!Contract.invio_lett_intenti__c}" />
                            <apex:outputField value="{!Contract.Type__c}"/>
                            <apex:outputField value="{!Contract.Tipo__c}"/> 
                            <apex:outputField value="{!Contract.agente__c}"/>
                            <apex:outputField value="{!Contract.Status}"/>
                            <apex:outputField value="{!Contract.accordo_prog__c}"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
                        
                    <apex:pageBlockSection id="section2" columns="2" title="Condizioni Commerciali">
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:outputField value="{!Contract.invio_lett_intenti__c}"/>
                            <apex:outputField value="{!Contract.ricez_lettera_intenti__c}" />
                            <apex:outputField value="{!Contract.StartDate}"/> 
                            <apex:outputField value="{!Contract.endContractDate__c}" />
                            <apex:outputField value="{!Contract.discount__c}"/>
                            <apex:outputField value="{!Contract.contract_sign_date__c}"/> 
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>  
                        
                    <apex:pageBlockSection id="section3" columns="2" title="Dati per Accordo Progettazione" rendered="{!Contract.accordo_prog__c=='Si'}">
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:inputField value="{!Contract.CreatedById}"/>
                            <apex:inputField value="{!Contract.LastModifiedById}"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>      
                    
                    <apex:pageBlockSection id="section4" columns="2" title="Informazioni sul sistema">
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:inputField value="{!Contract.CreatedById}"/>
                            <apex:inputField value="{!Contract.LastModifiedById}"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>  
                </apex:actionRegion>
                    
                </apex:pageBlock>
                </apex:inlineEditSupport>
             </apex:form>
  </apex:define>
</apex:page>

Any help will be very appreciated!!!!!! I'm very frustrated :(
Thanks!
Hi everyone!
I've a little problem with a trigger. This trigger cicles on custom objects called Candidatura_Tenant__c and if a condition is ok, it calls a method (that creates another custom object)on a particular class. But for calling this method, I need to pass it the Id of the current Candidatura_Tenant__c, but the method creates the custom object withoud linking it to che current Candidatura_Tenant__c.
Here's the part of the trigger:
for(Candidatura_Tenant__c i: Trigger.new) {
        //search on candidatura_tenant all ID in the map
        Lead l = leads.get(i.Lead__c);
        String cnd = i.Id; // or ID cnd= i.Id; result is the same
        if(i.punteggio__c >= 21) {
            if(l.Country=='IT'){
                //assign the contact on candidatura
                List<Contact> cont = [SELECT c.Id FROM Contact c WHERE c.Name='Cristina Reginato' AND
                                     c.Account.Name = 'LAGO S.P.A.'];
                Contact contatto = cont.get(0);
                //i.contact_lago__c = '003c000000hafFz';
                i.contact_lago__c = contatto.Id;
                if (Trigger.isInsert == true){
                TaskHandler tsk = new TaskHandler();
                task_apt__c t = tsk.task_discover(Contatto,cnd,i.Lead__c);
                }
            }
.... and here's the method called by the trigger:
public class TaskHandler {
public task_apt__c task_discover(Contact cnt,ID cnd,ID lead){
task_apt__c task_disc = new task_apt__c();
task_disc.responsabile__c = cnt.Id;
task_disc.type__c = 'Candidatura Discover';
task_disc.RecordTypeId = '01213000001WGF7';
task_disc.state__c = 'Aperto';
task_disc.tipo_feedback__c = 'Risposta Libera';
task_disc.candidatura__c = cnd;
task_disc.task_end_date__c = date.today()+3;
task_disc.task_desc__c = 'Contatta il cliente per verificare e approvare la candidatura al progetto discover ';
task_disc.lead_name__c = lead;
insert task_disc;
return task_disc;
}
//metodo che crea la task di tipo discover (2016) 
}
Any help?
Thanks in advance
HI, I have a problem with this trigger, I am not able to update the fields contact_lago__c :(
Here's the code:
//this trigger assign an owner for each Candidatura Discover based on score.
trigger AssignOwnerDiscover on Candidatura_Tenant__c (before insert,before update) {
    //Set<ID> ids = Trigger.newMap.keySet();
    List<Candidatura_Tenant__c> c = [SELECT Id,punteggio__c,contact_lago__c,Lead__r.Country FROM Candidatura_Tenant__c WHERE Id in :Trigger.newMap.keySet()];
    if (c.size()==0)
        return;
    for(Candidatura_Tenant__c i: c){
        if(i.punteggio__c >=21){
            if(i.Lead__r.Country=='IT')
                i.contact_lago__c ='003c000000hafFz';
            else 
                i.contact_lago__c ='003a000001v34dh';
        }
        else{
                if(i.punteggio__c >14)
                    i.contact_lago__c ='00313000028crUg';
                else
                    i.contact_lago__c =i.Lead__r.Agente__c;
        }
   }
}
Thanks in advance!
Hi everyone! I'm a little bit frustrated 'cause I'm trying to write a trigger like this:
trigger MediaTrigger on Media__c (after insert) {

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

    if (trigger.new[i].task__r.RecordTypeId=='01213000001WGQP'){

            List<task_apt__c> att=[select a.Id from task_apt__c a where a.Id=:trigger.new[i].task__c];

            task_apt__c attivita = att.get(0);

            List <Candidatura_Redesigner__c> cand=[select c.Id from Candidatura_Redesigner__c c where c.Lead__c=:attivita.lead_name__c];

            Candidatura_Redesigner__c cnd=cand.get(0);

            List<Media__c>md=[select m.Id from Media__c m where m.Id=:Trigger.new[i].Id];

            Media__c media=md.get(0);

            media.cand_redesigner__c=cnd.Id;

            update media;

        }

    }

}
But the object named media won't be updated after inserted.
Of course I'm wrong ..but I would like to know where is the error because I'm not able to find it out!
Thank you and have a nice day :)
Hi everybody, can someone help me with this simple trigger?
I want to assign in a lookup field of a custom object, an account name.
This object has a lookup fielld Contract__c.
Here's the trigger:

trigger AssignAccountProjectTrigger on Progetti__c (after insert) {
    for (Integer i = 0; i < Trigger.new.size(); i++){
        List <Progetti__c> prg = [select p.Id
            from Progetti__c p where p.Id = :Trigger.new[i].Id];
        if (prg.size() == 0 || prg.size() >1)
           return;
        else{
            Progetti__c p=prg.get(0);
            List <Account> acc = [select a.Id,a.Name from Account a where a.Id=:p.contract__r.Account.Id];
            Account cliente=acc.get(0);
            p.account__c = cliente.Id;
            update p; 
        }   
    }
}

Thank you in advance.
 
Hi everyone!
My boss is doing a query on SOQL using API REST, but he need a query that involves a global research of all users recycle bin.
We discovered that is possible only to make a query in our recycle bin.
Is there a way to take all recycledbin objects in the query?
Hi everybody , I have troubles with my code.
What I have to do is update a Field in a object with the same field taken from another object.

I'm trying this with a trigger , here's the code below :

trigger TriggerCreateTaskBroker on Candidatura_Tenant__c (after update)
{
  for (Integer i = 0; i < Trigger.new.size(); i++) 
   {
        if (Trigger.new[i].selected__c != Trigger.old[i].selected__c && Trigger.old[i].selected__c == null && Trigger.new[i].selected__c == 'Si')
      {
          Task_apt__c obj = new Task_apt__c();
          obj.type__c = 'Attivazione Playourhouse';
          obj.responsabile__c = Trigger.old[i].agente_cand__c;
          obj.RecordTypeId = '012a0000001WEaI';
          obj.task_desc__c = 'prova trigger roger x agente';
          obj.phone__c = 20142014;
          insert obj;
          //BookInsert.put(obj.id,obj);
      }
   }
}

The problem is that in the class test, the assert that I've set is wrong,Expected 0, actual 1. So, probably my trigger doesn't do what  have to do.
Anybody has some idea to solve my problem?
thsnk you in advance
Hi, I'm trying to build a trigger that create an object when a checkbox cames to true value , here is the code :

trigger CreateTask on Container_Trigger__c (after update)
{
    //Map<ID,Book__c> BookInsert = new Map<ID,Book__c>
    //{
       
   // };
  for (Integer i = 0; i < Trigger.new.size(); i++)  
   {
        if (Trigger.new[i].Enable_TriggerBook__c != Trigger.old[i].Enable_TriggerBook__c && Trigger.old[i].Enable_TriggerBook__c == false)
      {
          Task_apt__c obj = new Task_apt__c();
          //obj.type__c = Post Vendita;
          //obj.responsabile__c = 003a000001v34bp;
          //obj.RecordType = 01Ia0000002Rcl2;
          obj.phone__c = 000000000;
          insert obj;
          //BookInsert.put(obj.id,obj);
      }
   }
}

The error is : Error: Compile Error: Incorrect SObject type: Container_Trigger__c should be task_apt__c at line 1 column 1
I really have no idea how to solve..please give me a hand :)
Thanks in advance
Hi everybody , my issue is about a visualforce page in which I want to see a different section based on different picklist values.

Now, I've tried different ways to find out with no results :(

I'll paste my code now, can you please suggest me how to solve my problem?
Thanks in advance

<apex:page standardController="pacchetto_mkt__c">
    <apex:variable value="{!pacchetto_mkt__c.Contract__c}" var="contract"/>
     <apex:variable value="{!pacchetto_mkt__c.AccountF__c}" var="account"/>
     <apex:variable value="{!pacchetto_mkt__c.Tipologia__c}" var="tipologia"/>
        <apex:define name="Header">
         <apex:sectionHeader title="{!$ObjectType.pacchetto_mkt__c.label}" subtitle="{!pacchetto_mkt__c.name&' per '&$ObjectType.Account.label&' : '&pacchetto_mkt__c.Contract__r.Account.Name}"/>
            <apex:form >
                <apex:pageBlock mode="edit">
                    <apex:pageBlockButtons location="top">
                        <apex:commandButton value="Save" action="{!save}"/>
                        <apex:commandButton value="Cancel" action="{!cancel}"/>
                        <apex:commandButton action="{!edit}" value="Edit"/>
                        <apex:commandButton action="{!delete}" value="Delete"/>
                    </apex:pageBlockButtons>
                    <apex:actionRegion >
                    <apex:pageBlockSection columns="2" title="Pacchetto Marketing">
                        <apex:inputField value="{!pacchetto_mkt__c.anno_opzione__c}"/>
                        <apex:outputField value="{!pacchetto_mkt__c.AccountF__c}"/>
                        <apex:inputField value="{!pacchetto_mkt__c.Contract__c}"/>
                        <apex:inputField value="{!pacchetto_mkt__c.quantita__c}"/>
                        <apex:inputField value="{!pacchetto_mkt__c.Tipologia__c}">
                            <apex:actionSupport event="onchange" rerender="youtube"/>
                        </apex:inputField>
                        <apex:inputField value="{!pacchetto_mkt__c.price_pkt__c}"/>
                        <apex:pageBlockSection columns="1">
                            <apex:inputField value="{!pacchetto_mkt__c.start_date__c}"/>
                            <apex:inputField value="{!pacchetto_mkt__c.end_date__c}"/>
                        </apex:pageBlockSection>
                        <apex:pageBlockSectionItem >
                            <apex:outputLabel value="LastModifiedBy"/>
                            <apex:outputText >
                                <apex:outputField value="{!pacchetto_mkt__c.LastModifiedById}"/>&nbsp;
                                <apex:outputField value="{!pacchetto_mkt__c.LastModifiedDate}"/>
                            </apex:outputText>
                        </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                    </apex:actionRegion>
                    <apex:outputPanel id="youtube">
                        <!--<apex:pageBlockSection id="youtube" title="Dettagli Pacchetto" columns="1">-->
                            <!--<apex:pageBlockSection id="test" title="Dettagli Pacchetto" columns="1" rendered="{IF ISPICKVAL(!pacchetto_mkt__c.Tipologia__c,'Campagna web local Youtube - Start D'),true,false)}">-->
                        <apex:pageBlockSection id="section1" title="Dettagli Pacchetto" columns="1" rendered="{!pacchetto_mkt__c.Tipologia__c =='Campagna web local Youtube - Start D'}">
                           <apex:inlineEditSupport event="ondblClick">
                            <apex:inputField value="{!pacchetto_mkt__c.youtube_start__c}"/>
                            <apex:inputField value="{!pacchetto_mkt__c.youtube_end__c}"/>
                              </apex:inlineEditSupport>
                            </apex:pageBlockSection>
                        <!--</apex:pageBlockSection>-->
                        </apex:outputPanel>
                </apex:pageBlock>
            </apex:form>   
     </apex:define>
</apex:page>
Hi experts!
I have a little problem with a simple force.com site that I'm building.
I want to see a list of contacts with basic info, one of these info is a picklist field, but when I render the page, this picklist show the first value of list instead of the current value of the record.
Here's my VF Code of the picklist:
VF
<apex:pageBlockSectionItem >
                                    <apex:outputLabel value="{!$ObjectType.Contact.fields.type__c.label}" />
                                    <apex:selectList styleClass="slds-input"  value="{!statusOptions}"   size="1">
                                        <apex:selectOptions value="{!ItemsList}" rendered="true"/>
                                    </apex:selectList>
                                </apex:pageBlockSectionItem>
And the method of the controller:

public List<Selectoption> getItemsList(){
        List<SelectOption> options = new List<SelectOption>(); 
        List<Schema.Picklistentry> fieldResult = Schema.Contact.type__c.getDescribe().getPicklistValues();
        //options.add(new SelectOption());
        for(Schema.PicklistEntry f : fieldResult) {
            options.add(new SelectOption(f.getValue(), f.getLabel()));
        }
        return options;
    }

Any help will be very appreciated! Thanks in advance.
HI, I have a problem with this trigger, I am not able to update the fields contact_lago__c :(
Here's the code:
//this trigger assign an owner for each Candidatura Discover based on score.
trigger AssignOwnerDiscover on Candidatura_Tenant__c (before insert,before update) {
    //Set<ID> ids = Trigger.newMap.keySet();
    List<Candidatura_Tenant__c> c = [SELECT Id,punteggio__c,contact_lago__c,Lead__r.Country FROM Candidatura_Tenant__c WHERE Id in :Trigger.newMap.keySet()];
    if (c.size()==0)
        return;
    for(Candidatura_Tenant__c i: c){
        if(i.punteggio__c >=21){
            if(i.Lead__r.Country=='IT')
                i.contact_lago__c ='003c000000hafFz';
            else 
                i.contact_lago__c ='003a000001v34dh';
        }
        else{
                if(i.punteggio__c >14)
                    i.contact_lago__c ='00313000028crUg';
                else
                    i.contact_lago__c =i.Lead__r.Agente__c;
        }
   }
}
Thanks in advance!
Hi everyone! I've a little problem with a visualforce template.
I'd like to add in this template various fields on account parent object, but when I test with a test contact, I don't see any field of the related account :(
Here's a part of my code:
<messaging:emailTemplate recipientType="Contact"
    relatedToType="Contact"
    subject="CONDICIONES COMERCIALES PARA EL AÑO 2020"
    replyTo="web@lago.it" 
    >
    
<messaging:htmlEmailBody >        
    <html>
        <body>
            <div>
                <img src="https://www.lago.it/wp-content/uploads/2020/02/header-mail.png" style="width:60%;margin:5% 40% 5% 0%" border="0"></img>
            </div>
            <div style="margin-left: 40%;width:60%" align="left">
                <apex:variable var="Name" value="{!relatedTo.Account.Name}" />
                {!Name}<br/>
                {!relatedTo.Account.BillingStreet},{!relatedTo.Account.BillingCity}<br/>
                {!relatedTo.Account.BillingPostalCode},{!relatedTo.Account.BillingCountry}<br/>
                <apex:outputText id="PIVA" rendered="{!IF(relatedTo.Account.piva__c <> '' , 'true', 'false')}">
                    CIF: {!relatedTo.Account.piva__c}<br/> etc etc....

Any help will be appreciated..Have a nice day :)
Hi, we have a job that runs nightly, but from sunday, when trying to connect, we receive the following error:
Fault-tolerance-login-failed : There was a communication error when talking to Salesforce.com: Transport error: 302 Error: Found
​Any help will be accepted, thanks!
Hi, I have a problem with my visualforce. I would like to show a particular panel if I choose a record type, initially it works, but when I try to click save button, the records of the contract are not saved and the page remains as I left it.
Here' s my visualforce code:

<apex:page StandardController="Contract">
<apex:variable value="{!Contract.Account}" var="Account"/>
<apex:variable value="{!Contract.RecordType}" var="recordtype"/>
  <h1>Contract</h1>
  <apex:define name="Header">
         <apex:sectionHeader title="{!$ObjectType.Contract.label}" subtitle="Nuovo Contratto"/>
             <apex:form >
                <apex:inlineEditSupport event="ondblClick">
                <apex:pageBlock mode="view">
                    <apex:pageBlockButtons location="both">
                        <apex:commandButton value="Save" action="{!save}"/>
                        
                        <apex:outputPanel id="ContrattoProgettazione">
                        <apex:commandButton value="Contratto Progettazione" action="{! URLFOR($Action.Contract.Contratto_Progettazione, Id)}" rendered="{!Contract.accordo_prog__c=='Si'}"/>
                        <apex:inputField value="{!Contract.RecordTypeId}"/>
                        </apex:outputPanel>
                    </apex:pageBlockButtons>
                    <apex:actionRegion >
                 <apex:outputPanel id="Contratto_Shop" rendered="{!Contract.RecordTypeId = '01230000000EeSO'}">
                    <apex:pageBlockSection id="Shop1" columns="2" title="Dettagli Contratto Shop" >
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:outputField value="{!Contract.ContractNumber}" />
                            <apex:inputField value="{!Contract.AccountId}" required="true"/>
                            <apex:inputField value="{!Contract.Tipo__c}" required="true"/>
                            <apex:outputField value="{!Contract.agente__c}"/>
                            <apex:inputField value="{!Contract.Stato__c}" required="true"/>
                            <apex:outputField value="{!Contract.customercode__c}"/> 
                            <!--<apex:inputField value="{!Contract.Status}"/>-->
                            <apex:outputField value="{!Contract.PrimoContratto__c}"/>
                            <apex:inputField value="{!Contract.SpazioEsposizione__c}" required="true"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
                    <apex:pageBlockSection id="Shop2" columns="2" title="Condizioni" >
                        <apex:inlineEditSupport event="ondblClick">
                        <apex:inputField value="{!Contract.Type__c}" required="true"/>  
                        <apex:inputField value="{!Contract.contract_sign_date__c}"/>
                        <apex:inputField value="{!Contract.discount__c}" required="true"/>
                        <apex:inputField value="{!Contract.StartDate}"/>
                        <apex:inputField value="{!Contract.ChiaviInMano__c}"/>
                        <apex:inputField value="{!Contract.endContractDate__c}"/>
                        <apex:inputField value="{!Contract.ServizioOutlet__c}"/>
                        <apex:inputField value="{!Contract.addebito_spese__c}"/>
                        <apex:inputField value="{!Contract.data_start_add_spese__c}"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
                    <apex:pageBlockSection id="Shop3" columns="2" title="Budget" >
                        <apex:inlineEditSupport event="ondblClick">
                        <apex:inputField value="{!Contract.Budget_2016__c}"/>
                        <apex:inputField value="{!Contract.target_2016__c}"/>
                        <apex:inputField value="{!Contract.Budget_2017__c}"/>
                        <apex:inputField value="{!Contract.target_2017__c}"/>
                        <apex:inputField value="{!Contract.Budget_2018__c}"/>
                        <apex:inputField value="{!Contract.bdg_rinnovo_2016__c}"/>
                        <apex:inputField value="{!Contract.budget_2019__c}"/>
                        <apex:inputField value="{!Contract.rinnovo_2017__c}"/>
                        <apex:inputField value="{!Contract.sconto_prec__c}"/>  
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
               </apex:outputPanel>
               <apex:outputPanel id="Contratto_Discover" rendered="{Contract.RecordTypeId ==‘012a0000001W9qA'}">
                    <apex:pageBlockSection id="section1" columns="2" title="Dettagli Contratto Discover" >
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:inputField value="{!Contract.AccountId}"/>
                            <apex:inputField value="{!Contract.ContractNumber}" />
                            <apex:inputField value="{!Contract.Type__c}" required="true"/>
                            <apex:inputField value="{!Contract.Tipo__c}" required="true"/> 
                            <apex:inputField value="{!Contract.agente__c}"/>
                            <apex:inputField value="{!Contract.Status}" required="true"/>
                            <apex:inputField value="{!Contract.accordo_prog__c}" required="true"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>
                        
                    <apex:pageBlockSection id="section2" columns="2" title="Condizioni Commerciali">
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:outputField value="{!Contract.invio_lett_intenti__c}"/>
                            <apex:outputField value="{!Contract.ricez_lettera_intenti__c}" />
                            <apex:outputField value="{!Contract.StartDate}"/> 
                            <apex:outputField value="{!Contract.endContractDate__c}" />
                            <apex:outputField value="{!Contract.discount__c}"/>
                            <apex:outputField value="{!Contract.contract_sign_date__c}"/> 
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>  
                </apex:outputPanel>    
                    
                
                   <apex:pageBlockSection id="section4" columns="2" title="Informazioni sul sistema">
                        <apex:inlineEditSupport event="ondblClick">
                            <apex:inputField value="{!Contract.CreatedById}"/>
                            <apex:inputField value="{!Contract.LastModifiedById}"/>
                        </apex:inlineEditSupport>
                    </apex:pageBlockSection>  
                </apex:actionRegion>
                    
                </apex:pageBlock>
                </apex:inlineEditSupport>
             </apex:form>
  </apex:define>
</apex:page>
                   
Thank you in advance!!!
Hi everyone!
I've a little problem with a trigger. This trigger cicles on custom objects called Candidatura_Tenant__c and if a condition is ok, it calls a method (that creates another custom object)on a particular class. But for calling this method, I need to pass it the Id of the current Candidatura_Tenant__c, but the method creates the custom object withoud linking it to che current Candidatura_Tenant__c.
Here's the part of the trigger:
for(Candidatura_Tenant__c i: Trigger.new) {
        //search on candidatura_tenant all ID in the map
        Lead l = leads.get(i.Lead__c);
        String cnd = i.Id; // or ID cnd= i.Id; result is the same
        if(i.punteggio__c >= 21) {
            if(l.Country=='IT'){
                //assign the contact on candidatura
                List<Contact> cont = [SELECT c.Id FROM Contact c WHERE c.Name='Cristina Reginato' AND
                                     c.Account.Name = 'LAGO S.P.A.'];
                Contact contatto = cont.get(0);
                //i.contact_lago__c = '003c000000hafFz';
                i.contact_lago__c = contatto.Id;
                if (Trigger.isInsert == true){
                TaskHandler tsk = new TaskHandler();
                task_apt__c t = tsk.task_discover(Contatto,cnd,i.Lead__c);
                }
            }
.... and here's the method called by the trigger:
public class TaskHandler {
public task_apt__c task_discover(Contact cnt,ID cnd,ID lead){
task_apt__c task_disc = new task_apt__c();
task_disc.responsabile__c = cnt.Id;
task_disc.type__c = 'Candidatura Discover';
task_disc.RecordTypeId = '01213000001WGF7';
task_disc.state__c = 'Aperto';
task_disc.tipo_feedback__c = 'Risposta Libera';
task_disc.candidatura__c = cnd;
task_disc.task_end_date__c = date.today()+3;
task_disc.task_desc__c = 'Contatta il cliente per verificare e approvare la candidatura al progetto discover ';
task_disc.lead_name__c = lead;
insert task_disc;
return task_disc;
}
//metodo che crea la task di tipo discover (2016) 
}
Any help?
Thanks in advance
HI, I have a problem with this trigger, I am not able to update the fields contact_lago__c :(
Here's the code:
//this trigger assign an owner for each Candidatura Discover based on score.
trigger AssignOwnerDiscover on Candidatura_Tenant__c (before insert,before update) {
    //Set<ID> ids = Trigger.newMap.keySet();
    List<Candidatura_Tenant__c> c = [SELECT Id,punteggio__c,contact_lago__c,Lead__r.Country FROM Candidatura_Tenant__c WHERE Id in :Trigger.newMap.keySet()];
    if (c.size()==0)
        return;
    for(Candidatura_Tenant__c i: c){
        if(i.punteggio__c >=21){
            if(i.Lead__r.Country=='IT')
                i.contact_lago__c ='003c000000hafFz';
            else 
                i.contact_lago__c ='003a000001v34dh';
        }
        else{
                if(i.punteggio__c >14)
                    i.contact_lago__c ='00313000028crUg';
                else
                    i.contact_lago__c =i.Lead__r.Agente__c;
        }
   }
}
Thanks in advance!
Hi everyone! I'm a little bit frustrated 'cause I'm trying to write a trigger like this:
trigger MediaTrigger on Media__c (after insert) {

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

    if (trigger.new[i].task__r.RecordTypeId=='01213000001WGQP'){

            List<task_apt__c> att=[select a.Id from task_apt__c a where a.Id=:trigger.new[i].task__c];

            task_apt__c attivita = att.get(0);

            List <Candidatura_Redesigner__c> cand=[select c.Id from Candidatura_Redesigner__c c where c.Lead__c=:attivita.lead_name__c];

            Candidatura_Redesigner__c cnd=cand.get(0);

            List<Media__c>md=[select m.Id from Media__c m where m.Id=:Trigger.new[i].Id];

            Media__c media=md.get(0);

            media.cand_redesigner__c=cnd.Id;

            update media;

        }

    }

}
But the object named media won't be updated after inserted.
Of course I'm wrong ..but I would like to know where is the error because I'm not able to find it out!
Thank you and have a nice day :)
Hi everybody, can someone help me with this simple trigger?
I want to assign in a lookup field of a custom object, an account name.
This object has a lookup fielld Contract__c.
Here's the trigger:

trigger AssignAccountProjectTrigger on Progetti__c (after insert) {
    for (Integer i = 0; i < Trigger.new.size(); i++){
        List <Progetti__c> prg = [select p.Id
            from Progetti__c p where p.Id = :Trigger.new[i].Id];
        if (prg.size() == 0 || prg.size() >1)
           return;
        else{
            Progetti__c p=prg.get(0);
            List <Account> acc = [select a.Id,a.Name from Account a where a.Id=:p.contract__r.Account.Id];
            Account cliente=acc.get(0);
            p.account__c = cliente.Id;
            update p; 
        }   
    }
}

Thank you in advance.
 
Hi everybody , I have troubles with my code.
What I have to do is update a Field in a object with the same field taken from another object.

I'm trying this with a trigger , here's the code below :

trigger TriggerCreateTaskBroker on Candidatura_Tenant__c (after update)
{
  for (Integer i = 0; i < Trigger.new.size(); i++) 
   {
        if (Trigger.new[i].selected__c != Trigger.old[i].selected__c && Trigger.old[i].selected__c == null && Trigger.new[i].selected__c == 'Si')
      {
          Task_apt__c obj = new Task_apt__c();
          obj.type__c = 'Attivazione Playourhouse';
          obj.responsabile__c = Trigger.old[i].agente_cand__c;
          obj.RecordTypeId = '012a0000001WEaI';
          obj.task_desc__c = 'prova trigger roger x agente';
          obj.phone__c = 20142014;
          insert obj;
          //BookInsert.put(obj.id,obj);
      }
   }
}

The problem is that in the class test, the assert that I've set is wrong,Expected 0, actual 1. So, probably my trigger doesn't do what  have to do.
Anybody has some idea to solve my problem?
thsnk you in advance
Hi, I'm trying to build a trigger that create an object when a checkbox cames to true value , here is the code :

trigger CreateTask on Container_Trigger__c (after update)
{
    //Map<ID,Book__c> BookInsert = new Map<ID,Book__c>
    //{
       
   // };
  for (Integer i = 0; i < Trigger.new.size(); i++)  
   {
        if (Trigger.new[i].Enable_TriggerBook__c != Trigger.old[i].Enable_TriggerBook__c && Trigger.old[i].Enable_TriggerBook__c == false)
      {
          Task_apt__c obj = new Task_apt__c();
          //obj.type__c = Post Vendita;
          //obj.responsabile__c = 003a000001v34bp;
          //obj.RecordType = 01Ia0000002Rcl2;
          obj.phone__c = 000000000;
          insert obj;
          //BookInsert.put(obj.id,obj);
      }
   }
}

The error is : Error: Compile Error: Incorrect SObject type: Container_Trigger__c should be task_apt__c at line 1 column 1
I really have no idea how to solve..please give me a hand :)
Thanks in advance

Hi,

 

I am unable to get this to work.

I am trying to render a pageblock based on the selection of the picklist value. if the Opportunitystage=='Qualification' i want to then render the close date field.

in the below code i want to display the Closedate only when an Opportunity stage is selected and equals to "Qualification"

I don't know if i am doing any AJAX requests incorrectly.Can any one help me with this.

 

Page:

<apex:page standardController="Opportunity">
  <apex:form >
    <apex:pageBlock title="Edit Opportunity" id="thePageBlock" mode="edit">
   
      <apex:pageBlockButtons location="bottom" >
        <apex:commandButton value="Save" action="{!save}"/>
        <apex:commandButton value="Cancel" action="{!cancel}"/>               
      </apex:pageBlockButtons>

    <apex:pageBlockSection columns="1">
      <apex:inputField value="{!opportunity.name}"/>
      <apex:pageBlockSectionItem >
      <apex:outputLabel value="{!$ObjectType.opportunity.fields.stageName.label}" 
                        for="stage"/>
      <!-- 
           Without the actionregion, selecting a stage from the picklist would cause 
           a validation error if you hadn't already entered data in the required name 
           and close date fields.  It would also update the timestamp.
      -->  
    
      <apex:actionRegion renderRegiononly="{!opportunity.stageName !='Qualification'}" >
        <apex:inputField value="{!opportunity.stageName}" id="stage">
          <apex:actionSupport event="onchange" rerender="ajaxrequest"
                              status="status"/>
          </apex:inputField>
          </apex:actionRegion>
      </apex:pageBlockSectionItem>
        
       
        </apex:pageBlockSection>
        
          <apex:outputPanel id="ajaxrequest" rendered="{!Opportunity.StageName}" > 
              <apex:inputField value="{!Opportunity.CloseDate}"/>
             {!text(now())}
          </apex:outputPanel> 
        
      </apex:pageBlock>
    </apex:form>
</apex:page>

Thanks,

Sales4ce