• Leonardo Alves
  • NEWBIE
  • 50 Points
  • Member since 2014


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 16
    Replies
Hello everyone,

I created a VF form for my org, which i created a custom object for, and some of my users are getting an error when trying to create a new form from an opportunity related list. If they create it directly from the custom object tab then there isnt any problems. The error is 'Id not specified in an update call'. I have 2 different profiles that use this form and only one of the profiles recieves this error. The other profile has no problem. I will post the code for the form if need be, however it consists of 5 different VF pages, an apex class and the test class to go along with it. I didnt want to post all of the code and confuse anyone if the problem was some salesforce setting or declaritive change that i can make, but i will post the code if necessary. The two profiles have different page layouts for most if not all objects as well as different custom fields, but the custom fields related to the form are identical as are any cross object lookups used by the form. I will post any information or code needed, but like i said earlier, i didnt want to post hundreds of lines of code and confuse anyone. Please advice as soon as possible.

Thanks
Hello
how do I run an action after click in the YES option message?
Thank you
<apex:column >
        <apex:commandButton value="X" onClick="if (!confirmation()) return false; else callDeleteJob('{!ac.CronJobDetail.Name}'); return false;" />
 </apex:column>

hi community, I'm anxious to deploy my trigger, but my code coverage is bad <75% =(

My trigger:
trigger InsertDeploymentProject on Opportunity (after insert, after update) {
	List<Projeto_Implantacao__c> pi = new List<Projeto_Implantacao__c>();
	Projeto_Implantacao__c projeto;
	Map<Id, Schema.RecordTypeInfo> rtMap = Schema.SObjectType.Opportunity.getRecordTypeInfosById();
	Set<Id> accountIds =  new Set<Id>();
	
	for(Opportunity o:Trigger.new){
		accountIds.add(o.AccountId);
	}
	Map<Id, Account> accountMap = new Map<Id, Account>([SELECT Name FROM Account WHERE Id IN :accountIds]);
	
	
	if(Trigger.isAfter) {
    if(Trigger.isUpdate) {
       for(Opportunity o: Trigger.new) {
       	for(Opportunity old: Trigger.old) {
           if(o.Id==old.id && o.IsWon  ){
           	 
             projeto = new Projeto_Implantacao__c();
             
             projeto.Name = 'Imp - '+ accountMap.get(o.AccountId).Name + ' - ' + rtMap.get(o.RecordTypeId).getName();
             projeto.Implantacao__c = o.AccountId;
             projeto.Status__c = 'Aguardando início';
             pi.add(projeto);           
           }
       	}   
       }       
    }
    if(!pi.IsEmpty())
      insert projeto;
  }
}

My test:

@isTest private class TesteInsertDeploymentProject {

    @istest static void TestDeploymentProject() {
	Account account = new Account();
	account.Name = 'Nome da conta de teste';
	account.Telefone_2__c = '(067) 3027-9600';
	account.Phone = '(067) 3027-9600';
	account.Classificacao_PAF_ECF__c = 'Sem ECF + Não PAF';
	account.CNPJ__c = '86.571.322/0001-06';
	account.Unidade_de_atendimento__c = 'Campo Grande';
	String accid = account.Id;
	
	insert account;
	
	Opportunity opp = new Opportunity();
	opp.Name = 'Opp';
	opp.AccountId = account.Id;
	opp.ForecastCategoryName = 'Funil';
	opp.CloseDate = Date.today();
	opp.StageName = 'Negocição e revisão';
	opp.Expectativas_do_cliente__c = 'Test';
	opp.Numero_de_licencas__c = 1;
	opp.Amount = 1;
	opp.Valor_Implantacao__c = 1;

	String op = opp.Id;
	
	insert opp;
	
	Projeto_Implantacao__c projeto = new Projeto_Implantacao__c();             
	System.debug(projeto.Name = 'Imp - '+ opp.AccountId + ' - ' + opp.RecordTypeId);
	System.debug(projeto.Implantacao__c = opp.AccountId);
	System.debug(projeto.Status__c = 'Waiting for start');
	insert projeto;
	
	System.debug(opp.StageName = 'Close and won');
	update opp;
	
	projeto = new Projeto_Implantacao__c();             
	System.debug(projeto.Name = 'Imp - '+ opp.AccountId + ' - ' + opp.RecordTypeId);
	System.debug(projeto.Implantacao__c = opp.AccountId);
	System.debug(projeto.Status__c = 'Waiting for start');
	insert projeto;
	
	opp.StageName = 'Close and Lost';
	update opp;
	
	projeto = new Projeto_Implantacao__c();             
	System.debug(projeto.Name = 'Imp - '+ opp.AccountId + ' - ' + opp.RecordTypeId);
	System.debug(projeto.Implantacao__c = opp.AccountId);
	System.debug(projeto.Status__c = 'Waiting for start');
	insert projeto;
	          
	projeto = new Projeto_Implantacao__c();             
	System.debug(projeto.Name = 'Imp - '+ opp.AccountId + ' - ' + opp.RecordTypeId);
	System.debug(projeto.Implantacao__c = opp.AccountId);
	System.debug(projeto.Status__c = 'Waiting for start');
	insert projeto; 
	
	
	
    }
}


I'm writing some triggers and I have difficult to deploy because I have difficult to create test class.

I saw various docs but they not helped a lot. 

Anyone help me?

Tnx.
 

How would I write a test class for each of these two codes I am beyond confused with Apex. The triggers just update the Last_activity_type__c field when a new activity is logged.

List<Id> OpportunityIds = new List<Id>();
List<Opportunity> OpportunityList = new List<Opportunity>();

for(Task t :trigger.new)
    {
    if(t.whatid!=null)
    {
        Schema.SObjectType tType= t.whatid.getSObjectType();
        if(tType == Opportunity.Schema.SObjectType)
        {
            OpportunityIds.add(t.Whatid);
        }
    }
    }
    {
    //Querying the related Opportunity based on whatid on Task
    Map<Id,Opportunity> OpportunityMap =  new Map<Id,Opportunity>([select id,Last_Activity_Subject__C from Opportunity where id in:OpportunityIds]);
  
    for(Task t :Trigger.new)

        for(Opportunity l : OpportunityMap.Values())
        {
            l.Last_Activity_Subject__C = t.subject;
            OpportunityList.add(l);
        }
    }
    // updating the Opportunity
    if(OpportunityList.size()>0)
    {
        update OpportunityList;
    }
}

trigger updateRelatedLead on Task (after insert,after update) {

List<Id> LeadIds = new List<Id>();
List<Lead> LeadList = new List<Lead>();

for(Task t :trigger.new)
    {
    if(t.whoId!=null)
    {
        Schema.SObjectType tType= t.whoId.getSObjectType();
        if(tType == Lead.Schema.SObjectType)
        {
            LeadIds.add(t.WhoId);
        }
    }
    }
    {
    //Querying the related Lead based on whoId on Task
    Map<Id,Lead> LeadMap =  new Map<Id,Lead>([select id,Last_Activity_Subject__C from Lead where id in:LeadIds]);
  
    for(Task t :Trigger.new)

        for(Lead l : LeadMap.Values())
        {
            l.Last_Activity_Subject__C = t.subject;
            LeadList.add(l);
        }
    }
    // updating the Lead
    if(LeadList.size()>0)
    {
        update LeadList;
    }
}
Hello everyone,

I created a VF form for my org, which i created a custom object for, and some of my users are getting an error when trying to create a new form from an opportunity related list. If they create it directly from the custom object tab then there isnt any problems. The error is 'Id not specified in an update call'. I have 2 different profiles that use this form and only one of the profiles recieves this error. The other profile has no problem. I will post the code for the form if need be, however it consists of 5 different VF pages, an apex class and the test class to go along with it. I didnt want to post all of the code and confuse anyone if the problem was some salesforce setting or declaritive change that i can make, but i will post the code if necessary. The two profiles have different page layouts for most if not all objects as well as different custom fields, but the custom fields related to the form are identical as are any cross object lookups used by the form. I will post any information or code needed, but like i said earlier, i didnt want to post hundreds of lines of code and confuse anyone. Please advice as soon as possible.

Thanks
I am creating a VIsualforce which will be a News archive page listing items from my `News` object.
I would like the page to display a list of news article titles `name` field along with their created date displayed as the `publish date`. The page needs to have pagination.
Each row should be clickable which links to the detail page of the news item.

How can I acheive this using VisualForce?
I am attempting to deploy two fields and two triggers that place the Last Activity Subject into a field I made for leads and opportunities the triggers work perfectly in sandbox, but won't deploy in the production version. I am moving the two triggers along with the two fields the triggers reference. The code coverage listed in sandbox is 0% (0/14) for both I don't know if this is the problem, but they work perfectly and I haven't run into any problems when testing them in sandbox.

Here are the errors:
updateRelatedLead               Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required
updateRelatedOpportunity    Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required
Deploy Error                             Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required.

And the two codes:
trigger updateRelatedOpportunity on Task (after insert,after update) {

List<Id> OpportunityIds = new List<Id>();
List<Opportunity> OpportunityList = new List<Opportunity>();

for(Task t :trigger.new)
    {
    if(t.whatid!=null)
    {
        Schema.SObjectType tType= t.whatid.getSObjectType();
        if(tType == Opportunity.Schema.SObjectType)
        {
            OpportunityIds.add(t.Whatid);
        }
    }
    }
    {
    //Querying the related Opportunity based on whatid on Task
    Map<Id,Opportunity> OpportunityMap =  new Map<Id,Opportunity>([select id,Last_Activity_Subject__C from Opportunity where id in:OpportunityIds]);
   
    for(Task t :Trigger.new)

        for(Opportunity l : OpportunityMap.Values())
        {
            l.Last_Activity_Subject__C = t.subject;
            OpportunityList.add(l);
        }
    }
    // updating the Opportunity
    if(OpportunityList.size()>0)
    {
        update OpportunityList;
    }
}

trigger updateRelatedLead on Task (after insert,after update) {

List<Id> LeadIds = new List<Id>();
List<Lead> LeadList = new List<Lead>();

for(Task t :trigger.new)
    {
    if(t.whoId!=null)
    {
        Schema.SObjectType tType= t.whoId.getSObjectType();
        if(tType == Lead.Schema.SObjectType)
        {
            LeadIds.add(t.WhoId);
        }
    }
    }
    {
    //Querying the related Lead based on whoId on Task
    Map<Id,Lead> LeadMap =  new Map<Id,Lead>([select id,Last_Activity_Subject__C from Lead where id in:LeadIds]);
   
    for(Task t :Trigger.new)

        for(Lead l : LeadMap.Values())
        {
            l.Last_Activity_Subject__C = t.subject;
            LeadList.add(l);
        }
    }
    // updating the Lead
    if(LeadList.size()>0)
    {
        update LeadList;
    }
}
Hello
how do I run an action after click in the YES option message?
Thank you
<apex:column >
        <apex:commandButton value="X" onClick="if (!confirmation()) return false; else callDeleteJob('{!ac.CronJobDetail.Name}'); return false;" />
 </apex:column>

Hii

How do I get the value that is stored in a variable of the APEX controller and display its value in the input Text Visualforce??

APEX:
global String mail{get;set;}
global String name{get;set;}


name = 'MARIE';
mail='marie@gmail.com'


VISUALFORCE:

Mail..........:&nbsp;<apex:inputText value="{!mail}"/>
    
Name..:&nbsp;<apex:inputText  value="{!name}"/>
When opening the Visualforce page I would already see the name MARIE and the email  MARIE@GMAIL.COM into input text.

Help me