• JayDP123
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 14
    Replies

Hey!

 

Currently Iam using trial account so Iam unsure is there are any differences when you buy Force.com for 50$/user.

 

I know that the code coverage should be more then 75% if I would like to use automatic deployment to other organisations.

 

But what if me myself manage our Force.com and create new apex classes and triggers, which will have less then 75% coverage. Will our company users be able to use that classes and triggers if I create them in our application? 

 

Thanks for your explanation.

 

Best regards.

Hi,

 

I'm just starting with VisualForce (though I'm familiar with Apex), and I just was wondering about this aspect of VF code (easy solve and kudos for whoever wants on this one!). 

 

So when I create a "getter" method in apex, I just reference that by omitting the "get" part of the name. like:

 

public string getSomething

 

can be referenced by

{!something} . 

 

I guess this makes it easier to write getter methods, my question is, 

is this a common functionality within other programming languages? Or is it just for Salesforce?

Or what is the reason behind omitting the "get" part of the method, why does SalesForce not require it? 

 

I don't know why something so easy has me confused. Myabe it's a dumb question but if you can understand at all why I'm confused and want to help me out I'll appreciate it!!

 

thanks  

Hi,

 

Does SalesForce only allow 1 system.assertEquals in a test.method? I have tried with more than one but when I look at the test result it says only 1 test passed. 

 

Thanks

Hi,

 

I am just wondering if someone can explain when I am supposed to use Test.StartTest() and Test.StopTest() ? 

 

If I have a testmethod already, and the @istest notation, are the aforementioned methods necessary to perform a test? Can I run the test without them? When should I be starting-stopping? 

 

Thanks!!

Hi quick question,

 

does anybody know if it is possible to set the ownership of a record using the CreatedBy field? Because the createdby is not populated until the record is inserted a before insert would not work, I dont think. 

 

Is it commonplace to use an after insert to update the same record being inserted? 

 

Thanks! 

Heya,

 

I have a trigger to update ActivityDate field and Purpose__c multiselect picklist when a Task is Inserted or Updated. All of my system.debugs come up with the correct value, but nothing gets updated. Should I put it in an After Insert/Update maybe? I don't know why the fields aren't getting updated. 

 

trigger Task_SwayCard_AssignTask on Task (before insert, before update) {
	/* A trigger on the Task object that if the Task Owner is BDM or BDE,
			and the Subject of the task is like "Sway Card", then 
			the type of the task will change to Email, the due date of the task will
			be for the next coming Wednesday, and Sway Cards will be added
                        to purpose__c if it isn't already there.*/
    
    List<Task> tskSway = [SELECT id, ownerId, subject, purpose__c from Task 
                          where subject like '%Sway Card%' 
                          and id =: trigger.new]; // A list to hold "Sway Cards" tasks
    
    
    Date myDate = date.today();
    Date sunday = myDate.toStartOfWeek();
    Date nextSunday = sunday.addDays(7);
	Integer dayOfWeek = sunday.daysBetween(myDate);
    Date thisWednesday = sunday.addDays(3);
    Date nextWednesday = nextSunday.addDays(3);           
    	    
    System.debug(myDate);
    System.debug(sunday);
    System.debug(nextWednesday);
    
    If (tskSway != NULL){
    	system.debug('tskSway is Not Nulll!!');
        List<User> bdmOwner = [select id, name, userrole.name from user //A list to hold all BDMs in the org
        	                   where userrole.name like '%BDM%'];
    	List<User> bdeOwner = [select id, name, userrole.name from user
            	               where userrole.name like '%BDE%'];
		List<Task> tskToUpdate = new List<Task>();//A list to hold which tasks need to be updated
        
        For (Task t : tskSway) //Populate tskToUpdate based on whether the owner is a BDM or BDE, 
    	{						//and whether the Task is in the tskSway list.
        If (bdmOwner != null)
        {
     	   For (User u : bdmOwner)
        	{
            	If (u.id == t.ownerID)
            	{
                	tskToUpdate.add(t);            
            	}
        	}
        }
        If (bdeOwner != null)
        {
        	For (User u : bdeOwner)
            {
            	If (u.id == t.ownerID)
                {
            		tskToUpdate.add(t);
        		}
        	}
        }
        }
        
        If (tskToUpdate != null){
            System.debug('tskToUpdate is not Null!');
        For (Task t : tskToUpdate)
        {
            If (t.purpose__c.indexOf('Sway Cards') <= 0){
                system.debug('purpose has Sway Cards!' + t.purpose__c);
                t.purpose__c += ';Sway Cards;';
                system.debug(t.purpose__c);
            	}
            t.ActivityDate = nextWednesday;
            system.debug(t.ActivityDate);
        }
    }
    }
}

 

Hello, I have a trigger that is working on the Before Update, but is not working on Before Insert.

The idea is that when a Task is Inserted or Updated,

If the purpose__c = 'Sway Card, and Owner.Userrole contains 'BDM',

then set account.type = 'Suspect'

 

So as you can see it updates the Account Object, not sure if that has anything to do with it. Also purpose__c is a multi-picklist field. 

 

Anybody can help me out?

 

My code is here:  

 

trigger Task_SWayCard on Task (before insert, before update) {

List<ID> accID = new List<ID>(); //AccountIDs in the trigger
List<ID> ownerID = new List<ID>(); //Task Owners in the Trigger
for (task t : trigger.new)
{
If ( t.purpose__c == 'Sway Cards' )
{accID.add(t.AccountID);}
ownerID.add(t.ownerID);
}

If (accID != null)
{
list<Account> acc = [select id, name, ownerID, type from Account where Id =: accID]; //Accounts from the AccID list
List<User> owner = [select id, name, userrole.name from User where Id =: ownerID]; //Users from the ownerID list
List<User> bdmOwner = [select id, name, userrole.name from user where Id =: owner //Users where name like BDM
and userrole.name like '%BDM'];

List<Account> accToUpdate = [select id, name, type, ownerID from account where ownerID =:bdmOwner
and id =:acc];  //Selects the accounts we want to update

for (Account a : acc)
{
a.type = 'Suspect - Qualified';
update a;
system.debug(a.type);
}
}
}

 

Thanks!

Hello,

 

I have an Apex Trigger that I am trying to deploy through Change Sets from Sandbox to Production. It is a field update on the opportunity object. It works fine in Sandbox, and when I run tests I get 100% test coverage. However when I try to "validate" in the inbound change sets section in production I get errors like this: 

quoteExtTests.basicAttachTest()Class109 Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, JP_Opportunity: execution of BeforeInsert caused by: System.QueryException: List has no rows for assignment to SObject Trigger.JP_Opportunity: line 10, column 1", Failure Stack Trace: "Class.quoteE...
quoteExtTests.basicSaveTest()Class109 Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, JP_Opportunity: execution of BeforeInsert caused by: System.QueryException: List has no rows for assignment to SObject Trigger.JP_Opportunity: line 10, column 1", Failure Stack Trace: "Class.quoteE...

 

These Classes are from years ago, not even sure that they're still in use. I am new to deploying apex and not sure what they mean? Can someone help explain is this something to be concerned about? Can I ignore the test classes? Is it my code that is causing the issue? My code is below: 

 

trigger SF_Opportunity on Opportunity (before insert, before update) {
    
    //Change the Opportunity_Manager__c so the field is up to date with the current Opportunity Owner's Manager. 
    for (opportunity o : Trigger.new) {
        //get a list of the user object from the opportunity owner. 
        List<User> oppOwner = [select managerid, name, UserRole.name from user where user.id =: o.ownerid];
        system.debug('USER LIST ***' + oppOwner);
    for (user oppOwn : oppOwner){
            //update the fields based on the id of the opportunity owner
          o.Opportunity_Owner_Manager__c = [select name from user where user.id =: oppOwn.managerid].name;
          o.Opp_Owner_Role__c = [select name from UserRole where UserRole.id =: oppOwn.UserRoleID].name;
        }
  }
}

 

Thanks for the help, again I am new to this just trying to learn as much as I can.

 

Thanks! 

Hi, I am a beginner developer looking for some help.

 

I am having trouble getting a simple list of all sObjects on a visualForce page. I have seen some examples which use SelectOption lists but I would rather have it in a column in a pageblocktable.

 

I can get the Map<string, schema.sobjecttype> map = schema.getglobaldescribe(); which gives me all of the sObjects

 

but I don't know how to get that onto my page. Can anyone help? I am really not good with (get; set;) and I figure that is the way to go. Maybe just a little guidance?  

 

 

 

 

 

List<string> s =new list<string>{'CESSSSS'};
List<string> s1= new list<string>{'WA'};
List<string> s2= new list<string>{'NZ'};
List<account> acc = new list<account>();
for (account a :[select id,ownerid,billingstate from account where type='Prospect' and name != 's'])
{
    for (account b : s1)
    {
    if(b.billingstate == a.billingstate)
    { 
        a.ownerid='00591128657gfH5';
        acc.add(a);
    }
    }
}
 update acc;

 

  • March 15, 2013
  • Like
  • 0

Hi,

 

Does SalesForce only allow 1 system.assertEquals in a test.method? I have tried with more than one but when I look at the test result it says only 1 test passed. 

 

Thanks

Hi,

 

I am just wondering if someone can explain when I am supposed to use Test.StartTest() and Test.StopTest() ? 

 

If I have a testmethod already, and the @istest notation, are the aforementioned methods necessary to perform a test? Can I run the test without them? When should I be starting-stopping? 

 

Thanks!!

Hi quick question,

 

does anybody know if it is possible to set the ownership of a record using the CreatedBy field? Because the createdby is not populated until the record is inserted a before insert would not work, I dont think. 

 

Is it commonplace to use an after insert to update the same record being inserted? 

 

Thanks! 

Heya,

 

I have a trigger to update ActivityDate field and Purpose__c multiselect picklist when a Task is Inserted or Updated. All of my system.debugs come up with the correct value, but nothing gets updated. Should I put it in an After Insert/Update maybe? I don't know why the fields aren't getting updated. 

 

trigger Task_SwayCard_AssignTask on Task (before insert, before update) {
	/* A trigger on the Task object that if the Task Owner is BDM or BDE,
			and the Subject of the task is like "Sway Card", then 
			the type of the task will change to Email, the due date of the task will
			be for the next coming Wednesday, and Sway Cards will be added
                        to purpose__c if it isn't already there.*/
    
    List<Task> tskSway = [SELECT id, ownerId, subject, purpose__c from Task 
                          where subject like '%Sway Card%' 
                          and id =: trigger.new]; // A list to hold "Sway Cards" tasks
    
    
    Date myDate = date.today();
    Date sunday = myDate.toStartOfWeek();
    Date nextSunday = sunday.addDays(7);
	Integer dayOfWeek = sunday.daysBetween(myDate);
    Date thisWednesday = sunday.addDays(3);
    Date nextWednesday = nextSunday.addDays(3);           
    	    
    System.debug(myDate);
    System.debug(sunday);
    System.debug(nextWednesday);
    
    If (tskSway != NULL){
    	system.debug('tskSway is Not Nulll!!');
        List<User> bdmOwner = [select id, name, userrole.name from user //A list to hold all BDMs in the org
        	                   where userrole.name like '%BDM%'];
    	List<User> bdeOwner = [select id, name, userrole.name from user
            	               where userrole.name like '%BDE%'];
		List<Task> tskToUpdate = new List<Task>();//A list to hold which tasks need to be updated
        
        For (Task t : tskSway) //Populate tskToUpdate based on whether the owner is a BDM or BDE, 
    	{						//and whether the Task is in the tskSway list.
        If (bdmOwner != null)
        {
     	   For (User u : bdmOwner)
        	{
            	If (u.id == t.ownerID)
            	{
                	tskToUpdate.add(t);            
            	}
        	}
        }
        If (bdeOwner != null)
        {
        	For (User u : bdeOwner)
            {
            	If (u.id == t.ownerID)
                {
            		tskToUpdate.add(t);
        		}
        	}
        }
        }
        
        If (tskToUpdate != null){
            System.debug('tskToUpdate is not Null!');
        For (Task t : tskToUpdate)
        {
            If (t.purpose__c.indexOf('Sway Cards') <= 0){
                system.debug('purpose has Sway Cards!' + t.purpose__c);
                t.purpose__c += ';Sway Cards;';
                system.debug(t.purpose__c);
            	}
            t.ActivityDate = nextWednesday;
            system.debug(t.ActivityDate);
        }
    }
    }
}

 

Hi there,

 

I create a VF page on case.

And the page don't read the assignment rules.

 

So, I tried to use trigger.

But giving me a huge error, I don't even know how to figure out.

 

trigger AtribuicaoDeCasoTr on Case (after insert) {
    
	Database.DMLOptions dmo = new Database.DMLOptions();
	dmo.assignmentRuleHeader.useDefaultRule= true;

Case newCase = new Case(Status ='new');
newCase.setOptions(dmo);
insert newCase;

}

SF accept the code.

But when I will create a case. This error appears to me:

 

"AtribuicaoDeCasoTr: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AtribuicaoDeCasoTr: maximum trigger depth exceeded Case trigger event AfterInsert for [500J0000001IUue] Case trigger event AfterInsert for [500J0000001IUuf] Case trigger event AfterInsert for [500J0000001IUug] Case trigger event AfterInsert for [500J0000001IUuh] Case trigger event AfterInsert for [500J0000001IUui] Case trigger event AfterInsert for [500J0000001IUuj] Case trigger event AfterInsert for [500J0000001IUuk] Case trigger event AfterInsert for [500J0000001IUul] Case trigger event AfterInsert for [500J0000001IUum] Case trigger event AfterInsert for [500J0000001IUun] Case trigger event AfterInsert for [500J0000001IUuo] Case trigger event AfterInsert for [500J0000001IUup] Case trigger event AfterInsert for [500J0000001IUuq] Case trigger event AfterInsert for [500J0000001IUur] Case trigger event AfterInsert for [500J0000001IUus] Case trigger event AfterInsert for [500J0000001IUut]: [] Trigger.AtribuicaoDeCasoTr: line 8, column 1"

 

Thanks,.

Everton.

Hello, I have a trigger that is working on the Before Update, but is not working on Before Insert.

The idea is that when a Task is Inserted or Updated,

If the purpose__c = 'Sway Card, and Owner.Userrole contains 'BDM',

then set account.type = 'Suspect'

 

So as you can see it updates the Account Object, not sure if that has anything to do with it. Also purpose__c is a multi-picklist field. 

 

Anybody can help me out?

 

My code is here:  

 

trigger Task_SWayCard on Task (before insert, before update) {

List<ID> accID = new List<ID>(); //AccountIDs in the trigger
List<ID> ownerID = new List<ID>(); //Task Owners in the Trigger
for (task t : trigger.new)
{
If ( t.purpose__c == 'Sway Cards' )
{accID.add(t.AccountID);}
ownerID.add(t.ownerID);
}

If (accID != null)
{
list<Account> acc = [select id, name, ownerID, type from Account where Id =: accID]; //Accounts from the AccID list
List<User> owner = [select id, name, userrole.name from User where Id =: ownerID]; //Users from the ownerID list
List<User> bdmOwner = [select id, name, userrole.name from user where Id =: owner //Users where name like BDM
and userrole.name like '%BDM'];

List<Account> accToUpdate = [select id, name, type, ownerID from account where ownerID =:bdmOwner
and id =:acc];  //Selects the accounts we want to update

for (Account a : acc)
{
a.type = 'Suspect - Qualified';
update a;
system.debug(a.type);
}
}
}

 

Thanks!

Hi All.

 

In our organization we have a Task object consisting of 8 million records. Our ultimate task is to change the Last Modified Date(After opening up the field from SFDC support) in activities of the millions of records that were initially imported to SFDC from the previous system. Now, I cannot even do a query to get the exact number of records we're trying to export/import because it always times out.

 

The only criteria we have is OldSystem_Action_Id ! = null which separates the records originated in the old system.

 

I was thinking if we could utilize the batch functionality to break down the processes through the Apex Data Loader. If so, are you aware of any step by step procedures on how I can utilize this methodology. Also, will it be possible to extract the millions of records in separate files?

 

Any help is appreciated! Thanks in advance.

Hey!

 

Currently Iam using trial account so Iam unsure is there are any differences when you buy Force.com for 50$/user.

 

I know that the code coverage should be more then 75% if I would like to use automatic deployment to other organisations.

 

But what if me myself manage our Force.com and create new apex classes and triggers, which will have less then 75% coverage. Will our company users be able to use that classes and triggers if I create them in our application? 

 

Thanks for your explanation.

 

Best regards.

Hi, I am a beginner developer looking for some help.

 

I am having trouble getting a simple list of all sObjects on a visualForce page. I have seen some examples which use SelectOption lists but I would rather have it in a column in a pageblocktable.

 

I can get the Map<string, schema.sobjecttype> map = schema.getglobaldescribe(); which gives me all of the sObjects

 

but I don't know how to get that onto my page. Can anyone help? I am really not good with (get; set;) and I figure that is the way to go. Maybe just a little guidance?