• Ajinkya1225
  • NEWBIE
  • 187 Points
  • Member since 2016
  • Senior Consultant


  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 33
    Replies
Hi there everyone,

I have a test class that I am trying to create that is giving me grief. I have a test class that has added an entry to a Master object (Requests) and a related object (Time Entry). However, in order to get better coverage, I need to have at least three 'Time Entry' objects created so that various conditions are tested. There is also some totalling going on, so i need to have multiple Time entry objects in the same master object. The creation of the master object works ok, as well as the insert of the initial related object. However, when I try to create the 2nd and 3rd objects (Test2 & Test3) into 'Time Entry' I get the error message: 'INVALID_FIELD_FOR_INSERT_UPDATE, can not specify Id in an insert call:[Id]'

Below is what I believe to be the relevant portion of the code.
 
//Instantiate a new instance of the Custom Request Object.
        Request__c ReqObj = new Request__c();
    //Populate the name of the new request object.
        ReqObj.Name = 'Test request';
    //Populate 'What is being requested.
        ReqObj.What_is_being_requested__c = 'Entry to test apex code.';
    //Insert the new request object into Salesforce.
		insert ReqObj;	
        
    //Obtain the object Id for the request object created.     
        string ReqeustId = ReqObj.id;
		
	//Instantiate a new instance of the Time_Entry object.
		Time_Entry__c te = new Time_Entry__c();
    //Populate the required fields of the Time Entry object.
		te.Name ='Test1';												 
        te.Date_Worked__c = System.today();
        te.Hours_Worked__c = '01';
        te.Minutes_Worked__c = '15';
        te.Work_Description__c = 'This is a test entry';
        te.Activity__c = 'Research';
        te.Related_Object__c = ReqeustId.substring(0, 15);
    //Insert the new Time_Entry object into Salesforce.
		insert te;														 
		
    //Populate the required fields of the Time Entry object.
		te.Name ='Test2';												 
        te.Date_Worked__c = System.today();
        te.Hours_Worked__c = '02';
        te.Minutes_Worked__c = '00';
        te.Work_Description__c = 'This is a test entry';
        te.Activity__c = 'Research';
        te.Related_Object__c = ReqeustId.substring(0, 15);
    //Insert the new Time_Entry object into Salesforce.
		insert te;	
        
    //Populate the required fields of the Time Entry object.
		te.Name ='Test3';												 
        te.Date_Worked__c = System.today();
        te.Hours_Worked__c = '01';
        te.Minutes_Worked__c = '15';
        te.Work_Description__c = 'This is a test entry';
        te.Activity__c = 'Development';
        te.Related_Object__c = ReqeustId.substring(0, 15);
    //Insert the new Time_Entry object into Salesforce.
		insert te;														 
        
	//Indicate the starting of the test process. 
        Test.StartTest();




Any assistance would be greatly appreciated.

Thanks! - Eric -
Hello,

when you click on a record, it show a button sharing, when we click on it, it shows the some sharing rules, but how are the rules in sharing populated,
for example, one of the record it show that, its been shared to XYS Group.
How is it populated
  • August 31, 2016
  • Like
  • 0
Hi, Can somebody help with the following rule, which triggers when the field is empty even though it should not (that is why I used the OR function but something seems to be wrong with the formula:

AND (
OR(
 ISBLANK( Website ), 
AND(
   RIGHT(  Website , 4) <> ".COM",
   RIGHT( Website, 4) <> ".com",
   RIGHT( Website, 3) <> ".FR",
   RIGHT( Website, 3) <> ".fr",
   RIGHT( Website, 4) <> ".NET",
   RIGHT( Website, 4) <> ".net",
   RIGHT( Website, 4) <> ".org",
   RIGHT( Website, 4) <> ".ORG"
)))
Hi All,

We have run into a few issues lately where users of our salesforce instance are creating opporunities against accounts accounts that are 'Closed' are do not belong to us. I wont go into the reasons behind this as its quite complicated.

Bascially I'm trying to write a validation rule that will stop opportunities being created against Account numbers starting with '4' and/or accounts that are closed. These fields are currently not on the opportunity screen but do exist on the account screen.

Does anyone have any guidance as to how I can write the validation rule?
Hello, 

I have 14 record types that when a picklist from the Status is selected, the text field comments__c, but be required when saving a record. 

Can someone help me in figuring out the Validation Rule syntax for this? 

Here are my API details: 

Record Type IDs: 

012d0000000XHqhAAG
012d0000000hPmqAAE
012d0000000hPmvAAE
012d0000000XMJNAA4
012d0000000XNaIAAW
012d0000000XMJXAA4
012d0000000XMK1AAO
012d0000000XMKGAA4
012d0000000XNZPAA4
012d0000000XNZKAA4
012d0000000XNZFAA4
012d0000000XNZAAA4
012d0000000XNZUAA4
012d00000015DKuAAM

Text field API Name: 
Comments__c

Stauts API Name: 
Status

 
Hi Mates,

I'm working on creating  a managed package.Anyone has worked on the DevOps or CI of the managed package? I need suggestions on the four fronts:
 
1. Using namespaces on the soql query in the apex classes.
  • Resolution: name space can be queried in the apex class and on that a dynamic soql can be formed using schema class. This would help us in CI across different orgs.
  • Possible issue- Some objects have over 300 fields and we may run into heap size limit.
2. How to add namespace in vf page controllers during CI?
3. Namespace on Triggers during CI?
4. Using namespace while nesting lightning components?
 
Thanks in advance!
Ajinkya
Hi All,

I have a question- why the metadata <sitedotcomsites> are binary? Are there any best practices to be followed for site/community deployment for when using migration tool?

Thanks!
Ajinkya
Hi there everyone,

I have a test class that I am trying to create that is giving me grief. I have a test class that has added an entry to a Master object (Requests) and a related object (Time Entry). However, in order to get better coverage, I need to have at least three 'Time Entry' objects created so that various conditions are tested. There is also some totalling going on, so i need to have multiple Time entry objects in the same master object. The creation of the master object works ok, as well as the insert of the initial related object. However, when I try to create the 2nd and 3rd objects (Test2 & Test3) into 'Time Entry' I get the error message: 'INVALID_FIELD_FOR_INSERT_UPDATE, can not specify Id in an insert call:[Id]'

Below is what I believe to be the relevant portion of the code.
 
//Instantiate a new instance of the Custom Request Object.
        Request__c ReqObj = new Request__c();
    //Populate the name of the new request object.
        ReqObj.Name = 'Test request';
    //Populate 'What is being requested.
        ReqObj.What_is_being_requested__c = 'Entry to test apex code.';
    //Insert the new request object into Salesforce.
		insert ReqObj;	
        
    //Obtain the object Id for the request object created.     
        string ReqeustId = ReqObj.id;
		
	//Instantiate a new instance of the Time_Entry object.
		Time_Entry__c te = new Time_Entry__c();
    //Populate the required fields of the Time Entry object.
		te.Name ='Test1';												 
        te.Date_Worked__c = System.today();
        te.Hours_Worked__c = '01';
        te.Minutes_Worked__c = '15';
        te.Work_Description__c = 'This is a test entry';
        te.Activity__c = 'Research';
        te.Related_Object__c = ReqeustId.substring(0, 15);
    //Insert the new Time_Entry object into Salesforce.
		insert te;														 
		
    //Populate the required fields of the Time Entry object.
		te.Name ='Test2';												 
        te.Date_Worked__c = System.today();
        te.Hours_Worked__c = '02';
        te.Minutes_Worked__c = '00';
        te.Work_Description__c = 'This is a test entry';
        te.Activity__c = 'Research';
        te.Related_Object__c = ReqeustId.substring(0, 15);
    //Insert the new Time_Entry object into Salesforce.
		insert te;	
        
    //Populate the required fields of the Time Entry object.
		te.Name ='Test3';												 
        te.Date_Worked__c = System.today();
        te.Hours_Worked__c = '01';
        te.Minutes_Worked__c = '15';
        te.Work_Description__c = 'This is a test entry';
        te.Activity__c = 'Development';
        te.Related_Object__c = ReqeustId.substring(0, 15);
    //Insert the new Time_Entry object into Salesforce.
		insert te;														 
        
	//Indicate the starting of the test process. 
        Test.StartTest();




Any assistance would be greatly appreciated.

Thanks! - Eric -
Hey everyone-

We are reaching the 100 SOQL query per transaction in our custom Apex object. Is there a work around or way to get our limit increased?
Hi I am having this trigger . when my account name is already present status will updated as Y . and when address is already present then its not updating to Y .. why ?

trigger accountupdatestatus1 on Account (before insert) {
  list<account> acc = new list<account>(); 
  list<account> acc1 = new list<account>();
 for(account a: trigger.new)
 {
acc=[select id,name from account where name=:a.name];
  if(acc.size()>0)
  {
   a.Status__c = 'Y' ;
  }
 }
 for(account a1: trigger.new)
 {
acc1=[select id,name,BillingStreet from account where name=:a1.BillingStreet];
  if(acc1.size()>0)
  {
   a1.Status__c = 'Y' ;
  }
 }
}
How can we replace lookup option from name to any other field? 
Hello,

I have a custom object which is private and it has 3 lookups.
There are 200 records for this object in total but a user can see 100 records.

I have checked sharing criterias but the user is not part of this group, so i was thinking may it is related to lookup records.

thank you for suggestion !
  • September 01, 2016
  • Like
  • 0
All, need help. I`m getting an error at line 17 unexpected token: ')' and I cant figure out why. Can someone please help?
 
public class callout {


Settings__c ts = [SELECT Name, Client_Secret__c, ConsumerKey__c, Password__c, SecurityToken__c,Username__c from Settings__c];



String clientId = ts.ConsumerKey__c;
String clientSecret = ts.Client_Secret__c;
String username=ts.Username__c;
String password=ts.Password__c+ts.SecurityToken__c; 

String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;

Http h = new Http ();
HttpRequest req = new HttpRequest ();
req.setBody(reqbody);
req.setMethod('POST');
req.setEndpoint(ts.URL__c+'/services/oauth2/token');

HttpResponse res = h.send(req);
OAuth2 objAuthenticationInfo = (OAuth2)JSON.deserialize(res.getbody(), OAuth2.class);
RequestWrapper reqst=new RequestWrapper();
if(objAuthenticationInfo.access_token!=null){
Http h1 = new Http();
HttpRequest req1 = new HttpRequest();

req1.setHeader('Authorization','Bearer '+objAuthenticationInfo.access_token);
req1.setHeader('Content-Type','application/json');
req1.setHeader('accept','application/json');
req1.setBody(jsonstr);//Send JSON body
req1.setMethod('POST');
req1.setEndpoint(ts.URL__c+URL);
HttpResponse res1 = h1.send(req1);
system.debug('RESPONSE_BODY'+res1 .getbody());
}
}

 
Hello all

I have "contaminats" Object as a related list for Cases and the field in the objects were as follows (Name, Feed(CheckBox), Regeneration medium(CheckBox)). i need to Auto create 6 contaminats (oxygen,CO,H2,Olefins,Sulfur  components,Chloride components) upon case creation as unchecked
Can any one help me with a class to create these contaminats .
We have more number of users consider 100 users or more.
The user which will use only standard order object record.

Now if we buy Salesforce license it will cost too much per month/user.

So, is there any way to handle it with cheap way in the case of license?
Let me know best license suitable for this scenario.
 
Hello,

when you click on a record, it show a button sharing, when we click on it, it shows the some sharing rules, but how are the rules in sharing populated,
for example, one of the record it show that, its been shared to XYS Group.
How is it populated
  • August 31, 2016
  • Like
  • 0
Hi,

I have created a basic Salesforce site which allows users to enter data and it saves in a custom object.Along with this site-user also has to select a contact record to associate the data with contact. So I have created a lookup field to Contact object in my custom object. 

I have created a public group which contains guest user and from sharing rule i have granted read only permission to this group. Profile also has permission on contact and OWD for contact is private.

But when I click on lookfield in site it asks me authorization requested. Is it access issue? Can anyone please help me urgently on this.

Thanks,
Sumeet
Hi, Can somebody help with the following rule, which triggers when the field is empty even though it should not (that is why I used the OR function but something seems to be wrong with the formula:

AND (
OR(
 ISBLANK( Website ), 
AND(
   RIGHT(  Website , 4) <> ".COM",
   RIGHT( Website, 4) <> ".com",
   RIGHT( Website, 3) <> ".FR",
   RIGHT( Website, 3) <> ".fr",
   RIGHT( Website, 4) <> ".NET",
   RIGHT( Website, 4) <> ".net",
   RIGHT( Website, 4) <> ".org",
   RIGHT( Website, 4) <> ".ORG"
)))
Hi All,

We have run into a few issues lately where users of our salesforce instance are creating opporunities against accounts accounts that are 'Closed' are do not belong to us. I wont go into the reasons behind this as its quite complicated.

Bascially I'm trying to write a validation rule that will stop opportunities being created against Account numbers starting with '4' and/or accounts that are closed. These fields are currently not on the opportunity screen but do exist on the account screen.

Does anyone have any guidance as to how I can write the validation rule?
What is the use of SLA in Case.
Hello, 

I have 14 record types that when a picklist from the Status is selected, the text field comments__c, but be required when saving a record. 

Can someone help me in figuring out the Validation Rule syntax for this? 

Here are my API details: 

Record Type IDs: 

012d0000000XHqhAAG
012d0000000hPmqAAE
012d0000000hPmvAAE
012d0000000XMJNAA4
012d0000000XNaIAAW
012d0000000XMJXAA4
012d0000000XMK1AAO
012d0000000XMKGAA4
012d0000000XNZPAA4
012d0000000XNZKAA4
012d0000000XNZFAA4
012d0000000XNZAAA4
012d0000000XNZUAA4
012d00000015DKuAAM

Text field API Name: 
Comments__c

Stauts API Name: 
Status