• yashagarwal
  • NEWBIE
  • 55 Points
  • Member since 2011

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

Hi All,

 

Thanks in advance for any help on this topic.

 

Here is my code : 

   

String emailsubject = 'test1,test2,test3';
String emailbody= '100\n200\n300';
String[] emailSubjectIteams = emailsubject.split(',');
String[]  emailBodyMulti = emailbody.split('\n');
 List<Expense__c> expelement= new List<Expense__c>();
   Expense__c expItems = new Expense__c();
        for(integer i=0; i < emailSubjectIteams.size();i++)
                           {
    expItems.ExpName__c = emailSubjectIteams[i];
  expItems.Price__c = integer.valueOf(emailBodyMulti[i].substring(0));     
             expelement.add(expItems);           
      System.debug('expItems object'+expItems);
   System.debug('Expelement list values : '+expelement );     
              }

   

I am running the above code in System log to check my issue.  The Last system.debug line to print expelement shows a confusing result to me.

 

Please let me know if any one has any clue about this issue.

 

Regards,

 

NewSFDC

Hi,

 

I can easily dragged the text area field. How can i restrict user from dragging or stretching textarea??

 

Cheers,

Devendra S

Hi,

 

I am trying to call the chatter rest api from a visual force page from the same org. While my code works if I put it in the developer console - however , from the Visual force page I get the Http response 302 - not sure what is happening. Here is my apex code :

String salesforceHost = System.Url.getSalesforceBaseURL().toExternalForm();
        String url =  salesforceHost + '/services/data/v27.0/chatter/feeds/record/' + oTaskDetail.sato.Id + '/feed-items';
        HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint(url);
        req.setHeader('Content-type', 'application/json');
        req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId());
        String UserId = String.ValueOf(UserInfo.getuserId());
        String ChatterPostText = CreateChatterPost();
        req.setBody('{ "body" : { "messageSegments" : [ { "type": "mention", "id" : "' + UserId + '" }, { "type": "text",  "text" : "' + ' ' + ChatterPostText +  '" } ] } }');
        Http http = new Http();
        HTTPResponse res = http.send(req);

any help on this would be greatly appreciated. Thanks

Hi All,

 

I am creating csv file through apex class and vf page all things working fine only it creating first Row blank

it means data wirte from 2nd row instead of first row

 

 

Thanks,

Mayank  

Guys here is my vf page code:

<apex:page controller="addit" >
<apex:pageBlock title="Registration">
<apex:form >
<h1> Student Registration </h1><hr></hr>
<apex:pageBlockTable value="{!info}" var="new" id="stdid" width="100%" >
<apex:column >
       <apex:facet name="header"><b>Student Id</b></apex:facet>
{!new.Name}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Name</b></apex:facet>
{!new.name__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Date of Birth</b></apex:facet>
{!new.dob__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>College Name</b></apex:facet>
{!new.college_name__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Branch</b></apex:facet>
{!new.branch__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Year</b></apex:facet>
{!new.year__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Semester</b></apex:facet>
{!new.semester__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Roll No</b></apex:facet>
{!new.clgno__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Previous examid</b></apex:facet>
{!new.preexamid__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>10th percent</b></apex:facet>
{!new.ssc__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>12th percent</b></apex:facet>
{!new.hsc__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Emailid</b></apex:facet>
{!new.emailid__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Mobile</b></apex:facet>
{!new.phone__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Address</b></apex:facet>
{!new.address__c}
</apex:column>
<apex:column >
       <apex:facet name="header"><b>Accept/Reject</b></apex:facet>
       <a href="javascript&colon;if (window.confirm('Are you sure?')) DeleteAccount('{!new.Name}');" style="font-weight:bold">Del</a>

</apex:column>


</apex:pageBlockTable>
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel"/>
<apex:actionFunction action="{!DeleteAccount}" name="DeleteAccount" reRender="form" >
   <apex:param name="Name" value="" assignTo="{!SelectedAccountId}"/>
</apex:actionFunction>
</apex:form>
</apex:pageBlock>
</apex:page>

 

And here is my controller:

public class addit {
 public List<student__c> info { get; set; }
 
   //used to get a hold of the account record selected for deletion
   public string SelectedAccountId { get; set; }
   public addit(){
   LoadData();
   }
    public void DeleteAccount() {
         if (SelectedAccountId == null) {
      
         return;
      }
     
      // find the account record within the collection
      student__c tobeDeleted = null;
      for(student__c a : info)
       if (a.Name == SelectedAccountId) {
          tobeDeleted = a;
          break;
       }
      
      //if account record found delete it
      if (tobeDeleted != null) {
       Delete tobeDeleted;
      }
     
      //refresh the data
      LoadData();
       
    }
  private void LoadData() {
       info = [SELECT Name,name__c,dob__c,college_name__c,branch__c,year__c,semester__c,clgno__c,preexamid__c,ssc__c,hsc__c,emailid__c,phone__c,address__c FROM student__c];
   }

}

 

 

 

 

And i m getting this error since a long time

Error: Unable to complete the requested data change

Dont know wat is going wrong.Pls help....

 

I recently noticed that calling sendEmail from Apex code is limited to a certain number daily.  For Enterprise edition it's 500 emails per day.  I would have thought that Enterprise edition should have been much higher than that.  I have no idea how close our organization is to bumping up against that limit.  Is there a way to find out how many emails have been sent using sendEmail from Apex code?

Hi

 

I want to change the "competitors" name to "XXXX" in related list of opportunity, any body knows about that

please let me know....

 

Thanks!!!

  • August 16, 2011
  • Like
  • 0

Hi, 

I just created a new page in my app (by copying the structure of another page), and for some reason a datepicker without css appears at the end of the page.

When looking in the source, this datepicker is after the </apex:form>.

 

Does anybody know why this datepicker appears ?

 

Thanks for your help

  • August 16, 2011
  • Like
  • 0

Hi all,

     i have one object.the fields are in this object like f1__c,f2__c.These are picklists.i want the if  f1__c=='open' then

   f2__c='open'. 

              if( f1__c=='rejected') then f2__c=rejected.How to write this. using trigger or class. any one help me. can u please give me the sample code.

 

thanks in advance

anu

  • August 16, 2011
  • Like
  • 0

Hi all,

 

I am getting an error while writing test class on opportunity line item.

 

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId (pricebook entry currency code does not match opportunity currency code): [PricebookEntryId]

 

This is the error am getting please give me the solution as soon as possible.

 

Below is the code which i have written.....

 

 

@isTest
private class TestOpportunityProductLineCheck
{
    static testMethod void myTest()
   { 
            Opportunity o = new Opportunity(Id='006T0000008kKcc', Name = 'praveen', StageName='B - Prove', CloseDate = Date.today());
            update o;

            Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];

            Pricebook2 pb = new Pricebook2(Id='01s30000000A8FCAA0', Name= 'PSC Price Book', IsActive = true);
            update pb;
            
            Product2 prod = new Product2(Name = 'Orbix Product',IsActive = true);
            insert prod;
    
            
            PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
        insert standardPrice;
        
        PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
        insert pbe;

        
        //PricebookEntry pbe = new PricebookEntry(Pricebook2Id = '01s30000000A8FCAA0', Product2Id = prod.id, UnitPrice=100, UseStandardPrice = false, IsActive = true);
         //insert pbe ;
    
            
            //OpportunityLineItem ol = new OpportunityLineItem(OpportunityId = o.id , Quantity = 20 , TotalPrice = 100,PricebookEntryId = pbe.id );
            //insert ol;
    
            OpportunityLineItem oli = new OpportunityLineItem(opportunityId = o.Id, PricebookEntryId= pbe.Id, Quantity = 1, UnitPrice = 7500);
            insert oli;

List<OpportunityLineItem> olis = [Select Id From OpportunityLineItem Where OpportunityId =: o.Id];
        update olis[0];

            
 }
}



 

Thanks in advance.....

shruthika...


i have productlookup field in custom vf page,instead of selecting lookup field on type of the content in lookup ield need to save in a text box called new product ????????????

can anyone help me with this

  • August 16, 2011
  • Like
  • 0

Hi,

 

I have 3 apex batch jobs.

I run them in sequence. Lets call them BJ1, BJ2 and BJ3.

What I have noticed is that their execution time is very different. It seems to be dependent on,

 

1) the data in SF DB,

2) server congestion 

 

Yesterday it took me 4.5 hrs to run each job, which was ridiculous and in real scenario I need a solution to run them in sequence, so that I make sure that once BJ1 gets finished, then and only then BJ2 starts and once BJ2 gets finished BJ3 starts. And I also need to run them MORE THAN ONCE A DAY.

The interface jobs sceduler scedules the job once a day or I have to create multiple schedulers, which will be tedius as i'll need to schedule then every hour.

 

I need some help guys!!!! :smileysad:

  • August 16, 2011
  • Like
  • 0

We have an application where we process several orders in a batch. to process each order requires quite a bit of work and hence we have decided to have a batch size of 1 and process each order in a batch. That way the governor limits get reset for each order. now we are encountering a problem where suppose  an order has 1000 lines, we are hitting the script statement limit. It seems that to process these 1000 lines we can atmost have 200 scripts statements for each line before we run out of limits.

I find this restriction quite limiting. while i agree with the SOQL and memory limits, not being able to execute more script statements per batch seems very restrictive.

is there a way salesforce can increase the limits based on a fee. that way, our larger customers can pay an additional fee to process bigger orders.

so my question is if governor limits are fixed or can they be flexible based on a fee.

 

  • August 16, 2011
  • Like
  • 0

Hello

 

Is it possible to create trigger using meta data api?

(Creating objects and fields are possible i guesS)

if so, please share a sample code

 

Thanksin advance

  • August 16, 2011
  • Like
  • 0

Can I have an Workflow rule Email Notification on Opportunity Line Item.

 

I tried to create one , but I didnt able to find the Line Item fields in the Field Type values.

 

Can any one let me know.

  • August 14, 2011
  • Like
  • 0

Hi All,

 

Thanks in advance for any help on this topic.

 

Here is my code : 

   

String emailsubject = 'test1,test2,test3';
String emailbody= '100\n200\n300';
String[] emailSubjectIteams = emailsubject.split(',');
String[]  emailBodyMulti = emailbody.split('\n');
 List<Expense__c> expelement= new List<Expense__c>();
   Expense__c expItems = new Expense__c();
        for(integer i=0; i < emailSubjectIteams.size();i++)
                           {
    expItems.ExpName__c = emailSubjectIteams[i];
  expItems.Price__c = integer.valueOf(emailBodyMulti[i].substring(0));     
             expelement.add(expItems);           
      System.debug('expItems object'+expItems);
   System.debug('Expelement list values : '+expelement );     
              }

   

I am running the above code in System log to check my issue.  The Last system.debug line to print expelement shows a confusing result to me.

 

Please let me know if any one has any clue about this issue.

 

Regards,

 

NewSFDC

I pushed a trigger live a couple of weeks ago and it seemed to be working fine. But in the last two days, I've received 11 emails notifying me of an error. I've tested and can't duplicate the error and I'm not sure what's causing it. I think it must be an automated process that's trying to create an event because none of my users have complained about the error. How can I determine what is causing the error and how can I fix it?

 

Here's the error: 

 

Trigger.EventIndustry: line 28, column 38

Apex script unhandled trigger exception by user/organization: 00560000000m32k/00D600000006nRH

EventIndustry: execution of BeforeInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

 

Here's the code:

trigger EventIndustry on Event (before insert, before update) {
	if(trigger.isInsert){
        //create a set of all unique WhatIDs and WhoIDs
        set<id> WhoIDs = new Set<id>();
        Set<id> WhatIds= new Set<id>();
        Set<id> AccountIds= new Set<id>();
        
        for (Event t : trigger.new){
        	if (String.valueOf(t.whoId)!= null){
               	WhoIDs.add(t.WhoID); 
        	}else if (String.valueOf(t.WhatID)!= Null){
        		WhatIds.add(t.WhatID);
         	}else if (String.valueOf(t.AccountID)!= Null){
        		AccountIds.add(t.AccountID);
        	}
        }   
        //create a map for a hash table for the industry
       	Map<id, Lead> who = new Map<id, Lead>([SELECT Industry FROM Lead WHERE ID in :WhoIDs]);     
	   	Map<Id, Account> acct = new Map<Id, Account>([Select Industry From Account Where ID in :AccountIds OR ID in: WhatIDs]);
	   	Map<id, Contact> con = new Map<id, Contact>([SELECT Account.Industry from Contact WHERE ID in :WhoIDs]);
	   	Map<id, Opportunity> opp = new Map<id, Opportunity>([Select Account.Industry From Opportunity Where Id in :WhatIDs]);	
		
		// iterate over the list of records being processed in the trigger and set the industry
		for (Event a : Trigger.new){
			if (!who.isEmpty()){
		    	a.Industry__c = who.get(a.WhoId).Industry;
			} else if (!con.isEmpty()){
				a.Industry__c = con.get(a.WhoId).account.Industry;
			} else if (!opp.isEmpty()){
				a.Industry__c = opp.get(a.WhatId).account.Industry;
			} else if (acct != null && !acct.isEmpty()){
					if(acct.ContainsKey(a.whatID)){
						a.Industry__c = acct.get(a.whatID).Industry;
					}else if(acct.ContainsKey(a.AccountId)){
						a.Industry__c = acct.get(a.AccountId).Industry;
					}
			}
		}
	} else {
		if(trigger.isUpdate){
			 //create a set of all unique ids 
	        set<id> WhoIDs = new Set<id>();
	        Set<id> WhatIds= new Set<id>();
	        Set<id> AccountIds= new Set<id>();
			
			for (Event t : Trigger.new){
				if (Trigger.oldMap.get(t.Id).WhoId != Trigger.newMap.get(t.Id).WhoId){
					WhoIDs.add(t.WhoID); 
				}else if (Trigger.oldMap.get(t.Id).WhatID != Trigger.newMap.get(t.Id).WhatID){
					WhatIds.add(t.WhatID);
				}else if (Trigger.oldMap.get(t.Id).AccountID != Trigger.newMap.get(t.Id).AccountID){
					AccountIDs.add(t.AccountID);
				}
			}
			
			//create a map for a hash table for the industry
       		Map<id, Lead> who = new Map<id, Lead>([SELECT Industry FROM Lead WHERE ID in :WhoIDs]);     
	   		Map<Id, Account> acct = new Map<Id, Account>([Select Industry From Account Where ID in :AccountIds OR ID in: WhatIDs]);
	   		Map<id, Contact> con = new Map<id, Contact>([SELECT Account.Industry from Contact WHERE ID in :WhoIDs]);
	   		Map<id, Opportunity> opp = new Map<id, Opportunity>([Select Account.Industry From Opportunity Where Id in :WhatIDs]);	
			
			for (Event a : Trigger.new){
				if (!who.isEmpty()&& who.ContainsKey(a.WhoId)){
			    	a.Industry__c = who.get(a.WhoId).Industry;
				} else if (!con.isEmpty()){
					a.Industry__c = con.get(a.WhoId).account.Industry;
				} else if (!opp.isEmpty()){
					a.Industry__c = opp.get(a.WhatId).account.Industry;
				} else if (acct != null && !acct.isEmpty()){
					if(acct.ContainsKey(a.whatID)){
						a.Industry__c = acct.get(a.whatID).Industry;
					}else if(acct.ContainsKey(a.AccountId)){
						a.Industry__c = acct.get(a.AccountId).Industry;
					}
				}
			}
		}		
	}
}

 

Thanks,

 

Wendy

Hi,

I have written a email test class. But it is showing error 

 line breaks not allowed in string literals at line 13 column -1

 

my code is

@isTest
private class mailTest
{
    static testMethod void testMe()
    {
       Messaging.InboundEmail email = new Messaging.InboundEmail() ;
       Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
        
       email.subject = 'Test Job Applicant';
       email.fromname = 'Anu Raj';
       env.fromAddress = 'someaddress@email.com';

       mailTest.plainTextBody=('881754&#124;GoToMyPc access involving host
        10.1.6.240&#124;12183&#124;1523&#124;9&#124;4&#124;1312984923&#124;1&#124;completed, 881755&#124;Weather Bug activity from host
        10.1.6.64&#124;12183&#124;1523&#124;2&#124;4&#124;1313012808&#124;1&#124;completed, 882036&#124;ZmEu Exploit Scan from
        194.19.140.96&#124;6837&#124;8337&#124;585&#124;4&#124;1313024634&#124;1&#124;completed, 882083&#124;IBM Tivoli Storage Manager Express Backup counter heap corruption
        attempt&#124;8367&#124;8361&#124;16244&#124;4&#124;1313038745&#124;1&#124;completed, 882124&#124;EXPLOIT Internet Explorer DOM mergeAttributes memory corruption
        attempt &#124;5269&#124;5274&#124;47&#124;4&#124;1313072552&#124;1&#124;completed, 882137&#124;IRC traffic from 10.1.7.85&#124;12183&#124;6659&#124;NULL&#124;5&#124;1313075416&#124;1&#124;completed, 882172&#124;Host 10.1.6.162 is infected with Bredolab
        malware.&#124;12183&#124;6659&#124;2&#124;8&#124;1313074351&#124;1&#124;completed');
      
       
       mailprocess emailProcess = new mailprocess();
       emailProcess.handleInboundEmail(email, env);
        Account a = new Account();
        
       Case contact = [select account__c, begin_date__c, notification_approved__c, incident__c, created__c from case
       where account__c = :a.accountid__c];

       System.assertEquals(contact.account__c,'Account');
       System.assertEquals(contact.begin_date__c,'begin_date__c');
       System.assertEquals(contact.notification_approved__c,'notification_approved__c');
       System.assertEquals(contact.incident__c,'incident__c');
       
       
     //   a = [select name from attachment where parentId = :contact.id];

       System.assertEquals(a.name,'textfile.txt');


    }
}

 pleas help me

Thanks 

Anuraj

  • August 12, 2011
  • Like
  • 0

Hello,

 

I would enable the our users to select any document from a folder an attach it to an email.

I already have the functionality to select existing attachments and to upload a file, but I do not seem to get the correct list of document folders.

 

What I would like to do is:

A drop-down selectList to select the documents' folder.

Then a selectList to show the documents in the selected folder and let the user select the documents he wants to attach to the emailMessage.

 

Currently this is where I am stuck. The list of folders always contains every users' personal folder. I would rather use the same list that is displayed when accessing the Document object.

Is there any way to mimic the behavior of that picklist?

 

Regards,

hoomel

  • August 11, 2011
  • Like
  • 0

Hi,

 

I can easily dragged the text area field. How can i restrict user from dragging or stretching textarea??

 

Cheers,

Devendra S

I created a force.com site by adding a vf page called testPage in the active site home page and its working fine. But i have some links in testPage , when i click on the link it goes to the particular link's description which is in another vfpage called desc.

 

so how do i add the second vfpage to the existing site so that when i click on the link in testPage it should direct to the second page through force.com sites.