• nagalakshmi
  • NEWBIE
  • 145 Points
  • Member since 2011
  • tcs

  • Chatter
    Feed
  • 5
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 141
    Questions
  • 221
    Replies
trigger populateFields on Task (before insert,before update)
{
 map<id,list<task>> whoids = new map<id,list<task>>();
 for(task t :trigger.new)
 {
 if(t.whoid!=null)
 {
  if(!whoids.containsKey(t.whoid))
  {
  list<task> temp = new list<task>();
  temp.add(t);
  whoids.put(t.whoid,temp);
  }
  else
  {
  whoids.get(t.whoid).add(t);
  }
 } 

}
list<task> tasks = new list<task>();

for(contact c:[select id,Name, MobilePhone,Title from contact where id in:whoids.KeySet()])

{
//for(task t :whoids.get(c.id))
 
 for(task t :trigger.new) {
   t.Mobile__c =c.MobilePhone;
   t.Title__c =c.Title;
  tasks.add(t);
  }
  update tasks;
  
 }  
}



I create a contact
 and then a task , the mobile and title fields are not populated ....in task object ..and there is no error.

Hi everyone,

 

I am trying to create a Apex trigger that automatically creates a new task record for me once a checkbox field named "School Assigned" on my custom object, "Buffalo", is checked. I want a lot of the fields in the new task record to be automatically populated in the process. The code creates the new tasks fine, but unfortunately I have been having a lot of trouble setting up the code to populate the following default fields on the Task object: 1. Owner (AKA Assigned to) and 2. What (AKA Related to). The code is copied below, with the problem lines of code in blue and the corresponding error message I get in red. I know very little about Apex, any help is very much appreciated!

 

--------------------------------------------------------------------------------------------------------------------------------------------------------

 

trigger createTaskOnBuffaloX on Buffalo__c (after insert, after update) {

List <task> taskToInsert = new List <task> ();

for (Buffalo__c b : Trigger.new) {

if (b.School_assigned__c == true) {

task task = new task ();

task.ActivityDate = b.First_CO__c;
task.Subject = 'First CO';
task.owner = b.owner;   Error: Compile Error: Field is not writeable: Owner

task.what = b.name; Error: Compile Error: Illegal assignment from String to SOBJECT:Name



taskToInsert.add(task);


}//end if

}//end for o

try {
insert taskToInsert;
} catch (system.Dmlexception e) {
system.debug (e);
}

}

Hi Friends

 

I am new in visual force development .Dynamically how to create input text boxes based on the selected pick list value in visual force page. for ex: If the  picklist value is 4 , four text boxes will create in the visual force page. Please any one can guide me to achieve this problem..

 

Thanks

Sundar

Hi,

I have a lookup field in a object which is having filter on it. 
I am overriding new page with vf page. I have displayed this lookup filed in visualforce page. Which is displayed as readonly mode like user can not enter the value directly in it. User has to use the lookup icon to select the value. Once user select's a vlaue in it, it will give cross symbol to clear out the value from lookup field.

I have written onchange action support event on this lookup field to perform few validations. When i select the value in to lookup, event is firing and displaying the validation error message. But when i clear out the value using cross symbol, event is not firing and action is not performed. I want to fire an action when user clear out the value from this lookup. Kindly help me to solve this issue.
 
Hi,

i want to make the header = false for only service console from vf page. Used below code. But not working.

<apex:page controller="SVC_SelectDefectTypeController" title="Engineering Defect Creation" tabStyle="Engineering_Defect__c">
<apex:includeScript value="/support/console/30.0/integration.js"/>
 <script type="text/javascript"> 
     window.onload = function() {
          if (sforce.console.isInConsole()) {
              document.getElementById('AppBodyHeader').style.display = 'none';
          }
     };
</script>

</apex:page>

If i remove  this line if(sforce.console.isInConsole())  from code, it is working fine for both. But i want to make header false for only service console app. Please help me how to solve this.

Thanks,
Lakshmi
Hi,

I am redirecting to record url when the submit button is clicked from vf page. This is working fine in non service cloud and service cloud. 
But in service cloud, url is redirected to record and it is looking like non service cloud. It is coming out from service console. So i need to redirect to to the record of service console. How can i solve this issue.

Is there any direct method to know whether the console is service or not?? from apex class. Please help me out.Thanks in advance

Thanks,
Lakshmi
Hi,

I am unable to see the 'Edit' and 'delete' links in the account team related list in account record. I have 'Create, read, delete, edit, viewall' permissions for Account object. Please help me how to provide edit option for account team member related list.

Thanks,
Lakshmi.
Hi,

I am getting the error as'SendEmail failed. First exception on row 0; first error: UNVERIFIED_SENDER_ADDRESS, Organization-Wide Email Address has not be verified for use' from the test class. 

I have given the verified Organization-Wide Email Addresses to fromaddress field. Still i am facing the issue. Please let me know how can i solve the issue,

Thanks,
lakshmi.

Hi,

 

I have a visualforce page with component.. If i add that component in home page.. i need to display some text at right hand side (like popup or flash message) i.e for example account detail page. in the place of account detail page if i open account tab.. Like account i need to display vf component message for all standard obejcts.. Please help me if any solution.. Thanks in advance

 

Thanks,

Lakshmi

Hi,

 

I am trying to write test class for webservices class. I am getting error as 'Methods defined as TestMethod do not support Web service callouts, test skipped' . Please help me any one how to solve this.

 

 

Hi,

 

I have a rich text are field. I am saving data in table format in this field. I am unable to add columns for this table. Previously i am able to add columns and i am able to set the properties of table. Now after winter 14 updates i am unable to see these. Please help me any one.. How to add columns for existing table in richtext area..

 

Thanks,

Lakshmi

Hi,

 

I am generating pdf from visualforce page. I need to display one table at bottom of the page(only one page. that page is 2 page from last). How can i solve this. Please help me..

 

Thanks,

Lakshmi.

Hi,

 

how to retrieve parent object field from attachment query..

 

Thanks,

Lakshmi

Hi,

 

 

I have a static resource with image. I am trying to display one email template with this static resource image. But i am unable to get the image in to my inbox. Please help me out how to solve this.

 

 

Thanks,

Laskhmi

Hi,

 

My requirement is,  i need to add google plus button in to visualforce page. When we click on the google plus button it wil asks about gmail credentials. After login the count of gplus need to increase.

 

I have done this through javascript code. Its working fine in outside. But if keep the same code in visualforce page and i am trying to save this code, it is giving error as 

 

  Error: Unknown component g:plusone

 

<html>
<head>
<title>+1 demo: Basic page</title>
<link rel="canonical" href="http://www.example.com" />
<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
</script>
</head>
<body>
<g:plusone></g:plusone>
</body>
</html>

 

How can i achieve this through vf page. Please help me out....

 

 

Thanks,

Lakshmi

Hi,

 

Actually i have wrote one trigger for calculating roll up summery. It is working in my developer account. When i use the same code in client account. It will give the wrong value with double digits.. But in client account currecy type having NOK type. How can i display correct value... please help me...

 

This is my trigger:

 

trigger addingvalue on Case(after insert,after update)
{
id caserid;
set<id> pset=new set<id>();
id caseparentid;
//list<case> clist=new list<case>();
map<id,case> insertmap=new map<id,case>();
map<id,case> updatemap=new map<id,case>();
id feereasonid;
for(Case c:trigger.New)
{
caserid=c.recordtypeid;
if(c.Parentid!=null)
{
pset.add(c.parentid);
caseparentid=c.parentid;


}
system.debug(pset+'p===');
}
map<string,case> cmap=new map<string,case>([select Total_Compensation__c,Total_Reimbursement_Value__c from case where id in :pset]);
//string recordtypename=[select id,name from recordtype where id=:caserid limit 1].name;
feereasonid=schema.sobjecttype.case.getRecordTypeInfosByName().get('Feedback Reasons').getRecordTypeId();
//system.debug(recordtypename+'rrr==');
system.debug(cmap+'c===');
if(trigger.isinsert)
{
for(Case c1:trigger.New)
{
if(c1.recordtypeid ==feereasonid)
{
system.debug('sss===');
if(c1.Compensation_Value__c!=null)
{
if(cmap.get(c1.parentid).Total_Compensation__c==null || cmap.get(c1.parentid).Total_Compensation__c==0){
if(c1.Compensation_Value__c!=null)
cmap.get(c1.parentid).Total_Compensation__c=c1.Compensation_Value__c;}
else
cmap.get(c1.parentid).Total_Compensation__c=cmap.get(c1.parentid).Total_Compensation__c+c1.Compensation_Value__c;
}
if(c1.Reimbursement_Value__c!=null){
if(cmap.get(c1.parentid).Total_Reimbursement_Value__c==null || cmap.get(c1.parentid).Total_Reimbursement_Value__c==0)
cmap.get(c1.parentid).Total_Reimbursement_Value__c=c1.Reimbursement_Value__c;
else
cmap.get(c1.parentid).Total_Reimbursement_Value__c=cmap.get(c1.parentid).Total_Reimbursement_Value__c+c1.Reimbursement_Value__c;
}

system.debug(cmap.get(c1.parentid).Total_Compensation__c+'222==');
system.debug(cmap.get(c1.parentid).id+'pid==');

//clist.add(cmap.get(c1.parentid));
insertmap.put(cmap.get(c1.parentid).id,cmap.get(c1.parentid));
}
}
}
list<case> caselist=new list<case>();
double comp=0;
double Reimbursement=0;
set<id> upset=new set<id>();
map<id,double> caseMap=new map<id,double>();
map<id,double> caseMap1=new map<id,double>();
if(trigger.isupdate)
{
for(case cc:trigger.new)
{
if(cc.parentid!=null)
upset.add(cc.parentid);

}

for(AggregateResult q : [select parentid,sum(Compensation_Value__c) from case where parentid IN :upset group by parentid])
{
caseMap.put((Id)q.get('parentid'),(Double)q.get('expr0'));
}

for(AggregateResult q1 : [select parentid,sum(Reimbursement_Value__c) from case where parentid IN :upset group by parentid])
{
caseMap1.put((Id)q1.get('parentid'),(Double)q1.get('expr0'));
}

for(case cu:trigger.new)
{
if(cu.parentid!=null)
{
cmap.get(cu.parentid).Total_Compensation__c=caseMap.get(cu.parentid);
//update.put(cmap.get(c2.parentid).id, cmap.get(c2.parentid));
cmap.get(cu.parentid).Total_Reimbursement_Value__c=caseMap1.get(cu.parentid);
updatemap.put(cmap.get(cu.parentid).id, cmap.get(cu.parentid));
}
}
if(insertmap.size()>0)
update insertmap.values();
if(updatemap.size()>0)
update updatemap.values();
}
}

 

Thanks,

Lakshmi

Hi,

 

I am doing gotowebinar integration with salesforce. I am getting access token,refresh token,client id, organization key of gotowebinar in to salesfoce visualforce page. I have stored the accesstoken of gotowebinar in to one variable through apex class. When i am trying to get the data from gotowebinar to salesforce, it will throughs the error as

 

{"int_err_code":"InvalidToken","msg":"Invalid token passed"}

 

I have use the code for getting attendees details through this method.

 

public void performance()
{
s1=apexpages.currentpage().getparameters().get('code');
system.debug(accesstoken+'aaa==');
Http h = new Http();
HttpRequest req = new HttpRequest();
final string username = 'username';
final string password = 'welcome1';
//Blob headerValue = Blob.valueOf(username + ':' + password);
//String authorizationHeader = 'BASIC' + EncodingUtil.base64Encode(headerValue);
//req.setHeader('Authorization',authorizationHeader+accesstoken);
//String authorizationHeader = 'OAuth' +accesstoken +EncodingUtil.base64Encode(headerValue);
//req.setHeader('Authorization',authorizationHeader);
//req.setHeader('Authorization', 'OAuth ' +accesstoken);
//req.setHeader('Host','https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/attendees');
//req.setHeader('Authorization', 'OAuth '+accesstoken);
req.setHeader('Authorization:', 'OAuth oauth_token='+accesstoken);
//req.setHeader('Authorization: OAuth oauth_token=', accessToken);

req.setHeader('Connection','keep-alive');
req.setHeader('Content-Type', 'application/json;charset=UTF-8');
req.setMethod('GET');
//req.setEndpoint('https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/sessions/accesstoken/attendees/{registrantKey}');
//req.setEndpoint('https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/performance');
//req.setEndpoint('https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/sessions/'+accesstoken+'/performance');
req.setEndpoint('https://api.citrixonline.com/G2W/rest/organizers/4235772134427759365/webinars/106-020-667/attendees');
system.debug(accesstoken+'aaa1==');
system.debug(req+'hh==');
HttpResponse res = h.send(req);
system.debug(accesstoken+'aaa2==');
res2=res.getbody();
system.debug('********'+res.getbody());
system.debug('111=='+res.getstatus());

}

 

Please help me, how to solve this issue.. Thanks in advance..

 

Thanks,

Lakshmi

Hi,

How to display the batch apex job status dynamically in to visualforce page.
I am able to display the status when job starts, but i am unable to get the job status dynamically.
Means when job statrt it is queued after that job status is inprogress, completed. I need status dynamically for every 60 seconds. Please help me.

 

Thanks,

Lakshmi

Hi,

 

How to use the list view id in to apex class. If i know the list view id how can we get the records from object through query or standard controller method... etc. I need to get the values from listview using apex class. Please any one help me... I have tried a lot but i am unable to find the solution for this.

 

Thanks,

Lakshmi.

Hi,

 

I want to disply the account,contact,lead list views in to visual force page picklist. Please help me how can i solve this. I am able to display the single object listviews in to visualforce page. But not able to display all 3 objects listviews in to one single picklist. please help me..

 

Thanks,

Lakshmi

Hi,

 

Is there any authentication process with a string while inserting the record through visual force page like recaptcha. Please help me..

 

Thanks,

NagaLakshmi.B

Hi,

 

How to convert this string in to date. Please help me its very urgent.

 

Tue Nov 06 00:00:00 GMT 2012

 

Thanks,

Lakshmi

Hi,

 

Hi How can i use the list name for displaying the patner related list. If custom object, i used customobj__r as list. For partners i am getting error. How can use the name for list in below tag. Please help me..

<apex:relatedList list="Partners"/>

 

Thanks,

Lakshmi

Hi,

 

How to sort the list  as case insensitive. I am used the method as

 

listname.sort();

 

It will sort the records. But it will display the records in sort order which are having caps lock as first letter. After that display's the records in sort order which are having small letters as first letter. Please help me how sort the list as case insensitivly.

 

Thanks,

Lakshmi.

Hi guyz,

I'm trying to  display serial number of record using vfp, standard list control. using below code:
 
<apex:variable var="rowNo" value="{!0}"/>
            <apex:pageblocktable value="{!cnts}" var="cnt">
                <apex:column headerValue="Sl.No">
                    <apex:variable var="rowNo" value="{!rowNo+1}"/>
                    {!rowNo}
                </apex:column>
using above code for first colum,
here my problem is while using pagination in second page also serial no starts with 1. instead of 11,12,13..etc.
kindly give suggestion.
i'm a learner.
 
User-added image
Hi
In Account object When i click on custom button "Generate Students" an email goes to given email id in account.How can i get that
Thanks
hi ,
i have some trouble during implementation of test method .
Here i am trying to polulate a custom settings in test class but  it is shown that custom settings with that name is already exist .
Here i have a confusion  ,org data are accessible in test class without using (SeeAllData=true)  or not .
 
I have record type which is having thousands of records, and i created picklist field to show Records per page ( Values having 10, 25, 50, 100 ). In this i am selecting the picklist value and hit GO button manually to show correponding Records per page. But what I want is when I choose value, it have to load dynamically ( automatically without hitting GO Button )  for the chosen value.  

Thanks in Advance.


 
trigger populateFields on Task (before insert,before update)
{
 map<id,list<task>> whoids = new map<id,list<task>>();
 for(task t :trigger.new)
 {
 if(t.whoid!=null)
 {
  if(!whoids.containsKey(t.whoid))
  {
  list<task> temp = new list<task>();
  temp.add(t);
  whoids.put(t.whoid,temp);
  }
  else
  {
  whoids.get(t.whoid).add(t);
  }
 } 

}
list<task> tasks = new list<task>();

for(contact c:[select id,Name, MobilePhone,Title from contact where id in:whoids.KeySet()])

{
//for(task t :whoids.get(c.id))
 
 for(task t :trigger.new) {
   t.Mobile__c =c.MobilePhone;
   t.Title__c =c.Title;
  tasks.add(t);
  }
  update tasks;
  
 }  
}



I create a contact
 and then a task , the mobile and title fields are not populated ....in task object ..and there is no error.
Hi,

Is there any tool to check salesforce apex unused variables and methods..Kindly suggest.

Regards

Hi,

 

I am trying to write test class for webservices class. I am getting error as 'Methods defined as TestMethod do not support Web service callouts, test skipped' . Please help me any one how to solve this.

 

 

When i try update the data using data loader it was showing the error

 

ProductFieldUpdate: execution of BeforeUpdate

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

Trigger.ProductFieldUpdate: line 17, column 1

 

 

Code

trigger ProductFieldUpdate on Product2 (Before insert, before update){
    for(Product2 p : trigger.new){
   
        if(p.Ampics_PL__c != null && p.Ampics_PL__c == 'UTILUX'  ) {
        if(p.description.lastIndexOf('/') != -1) {
       
        Integer lastIndx = p.description.lastIndexOf('/');
        p.GPL_Desc__c  = string.valueOf(p.description.subString(lastIndx + 1));
        }
        else {
        p.GPL_Desc__c = '1';
         
        
             }
           }
        }
        }
      

Hi,

 

I am generating pdf from visualforce page. I need to display one table at bottom of the page(only one page. that page is 2 page from last). How can i solve this. Please help me..

 

Thanks,

Lakshmi.

Hi,

 

how to retrieve parent object field from attachment query..

 

Thanks,

Lakshmi

Hi,

 

 

I have a static resource with image. I am trying to display one email template with this static resource image. But i am unable to get the image in to my inbox. Please help me out how to solve this.

 

 

Thanks,

Laskhmi

HI,

 

I want to set default value for Required field of standard object. Before insert trigger is not working on that. Help me.

 

Eg: There is Last name in Lead, which is required field, what my business requirement is when i click on save without entering the field value in "Last Name",trigger would update "XYZ" value in that standard field.

 

Hope my requirement is clear. any help would be appreciated.

 

regards,

Taani

I am trying to write a batch apex job that will cycle through a list of records..

 

For each record, I need to get the VF Document related to it as a PDF and email it as an attachment.

 

The PDF always comes across as blank. I know I must bemissing something small because the exact same code works in a static apex class......

 

Can someone please help me resolve this?

 

Note: the code attached just attaches the file to the object for testing purposes...

 

this is the execute method. Everything else works except the actual PDF is empty

 

 

Map<ID,MYOBJECT__c> mFSA = New Map<ID,MYOBJECT__c>((MYOBJECT__c[])(database.query(query)));
    
    
    PageReference pr;
    blob pdf;
    
    For(FSA__c f : mFSA.values()){
    
        pr = New PageReference('/apex/ReportPDF?id=' + f.id ); 

        pdf = pr.getContentAsPDF();
        
        Attachment a = New Attachment();
        a.body = pdf;
        a.parentID = f.id;
        a.Name = 'FSA.pdf';
        insert a;
        
    
    }


 

Hi

 

I have the following query in my code

 

list<npo02__Household__c> DeleteHouseholds=[select Id from npo02__Household__c where Id NOT IN :TranHouseHoldIdSet];

 

 

     if(!DeleteHouseholds.isEmpty()&& xmlvalue[0].Households__c == true){
      delete DeleteHouseholds;
      }

 

 

But one of my client has 12000 dummy households which satisfies the above query.. But there is a limit of 10000 dml rows. So he is getting too many dml rows :10001 exception..

 

I know I can put a limit, but I want to delete all at a time..

 

Can any of you advice me please

 

Thanks

Anu

Hi,

 

I have seen other threads but none with a solution for my problem. I've created simple queries for the syndication feed on standard objects like accounts, but the information I need is in a custom object. The code looks like this:

 

 

select name from ts2__Job__c

 The error I get is this: 

 

Query: The SOQL for this feed refers to an invalid object type. Check the syntax of the query and make sure that any objects referenced are readable via your site's public access settings.

 I've made sure the object is readable, and I've even used the system log to make sure the query is valid. It does return results there, however not in the syndication field. Are there other limitations restricting me?

 

The custom object is managed, which may have something to do with it.

 

Any help is much appreciated!

 

 

I have a list in a page with an outputField and I notice if someone saves a long string with no spaces, most common is a URL, the string will not wrap and it breaks the page width.

 

 

If this string below was found anywhere in the field, is it possible to break that string apart at every X number of characters?

 

 

"this_is_a_long_line_with_no_line_breaks_it_should_be_split_at_every_172_characters_in_order_to_fit_into_the_page_with_out_breaking_the_page_width_repeat_this_is_a_long_line_with_no_line_breaks_it_should_be_split_at_every_172_characters_in_order_to_fit_into_the_page_with_out_breaking_the_page_width"

 

Where do I start? Would I make a string that is the X number of characters and get the size of that string then parse through the field for any strings with a length that matches my string to find what I want to break apart?

 

Then devide the found string by the length of my string for the number of times I need to loop through and split the found string with a space at every X number of characters?