• b-Force
  • PRO
  • 2222 Points
  • Member since 2010

  • Chatter
    Feed
  • 86
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 527
    Replies

I was wondering if something like this is possible through S controls and a JS button?

 

The attachment would need to be on the Service_Request__c object, but the Id for the visualforce page references a different object (Proposal__c)

 

I'm getting the error (Expected ';' ) and I can't tell where i'm going wrong...

 

{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
sforce.connection.serverUrl = '{!$Site.Prefix}/services/Soap/u/24.0';

try {
	var strQuery="Select Id from Proposal__c where Status__c = 'Awarded' and Service_Request__c = '"+'{!Proposal__c.Service_RequestId__c}'+"'";
	var LoeID = sforce.connection.query(strQuery);
	PageReference savePDF = new PageReference('/apex/vendorloe?rfpId='+LoeID);
	Blob pdfBlob = savePDF.getContent();
	var thisOb = new sforce.SObject("Service_Request__c");
		thisOb.Id = "{!Service_Request__c.Id}";
	var Atch = new sforce.SObject("Attachment");
		Atch.ParentId = thisOb.Id;
		Atch.Name = 'Letter of Engagement'+'.pdf'; 
		Atch.ContentType = 'pdf';
		ATch.Body = pdfBlob;
	
	result = sforce.connection.insert([Atch]);
} 
catch(er) {
	alert(er);
}

 

 

 

  • May 17, 2012
  • Like
  • 0

Hi there

 

WOrking on a custom object and was trying to add a Record Type to the object.

 

On the screen there is this paragraph:  "Select the Enable for Profile checkbox to make the new record type available to a profile. Users assigned to this profile will be able to create records of this record type, or assign this record type to existing records. To make the new record type the default for a profile, select the Make Default checkbox."

 

However, the Make Default checkboxes aren't even enabled.  Is it because this is the very first Record Type I'm adding to my custom object?  If so then all profiles will have to have that as the default record type?  

 

Under what condition will I be able to see the "Make Default" checkboxes enabled?  I don't know if I'm missing something here.  

 

I'm using the System Adm profile.

 

Thanks a lot!

 

 

 

Is it possible to update multiple records from a detail page button with the help of a query? I know it's possible to do this with a list, but here's the scenario:

 

User recommends child record - changes a status and a boolean. Other child records also need to have their boolean(s) toggled to true. However, the button is on the detail page - NOT a list. 

 

The following works great:

 

{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")}

var newRecords = [];

var thisP = new sforce.SObject("Proposal__c");
thisP.id = "{!Proposal__c.Id}";
thisP.Status__c = "Awarded";
thisP.test__c = true;
newRecords.push(thisP);

result = sforce.connection.update(newRecords);

location.reload(true);

 

 

However, I'm trying to introduce this, where Ideally i'd like to update other child records (with the same parent (Order__c) lookup)

 

{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")}

var newRecords = [];

var otherP = sforce.connection.query("Select Id from Proposal__c where Order__c = '{!Proposal__c.OrderId__c}'  ");
otherP.test__c = true;
newRecords.push(otherP);  //Add all other records to array?

var thisP = new sforce.SObject("Proposal__c");
thisP.id = "{!Proposal__c.Id}";
thisP.Status__c = "Awarded";
thisP.test__c = true;
newRecords.push(thisP);   //Add current detail page record to array

result = sforce.connection.update(newRecords);

location.reload(true);

 

  • April 23, 2012
  • Like
  • 0

Hi, 

 

I am trying to create a junction object between two custom objects. I keep getting this error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Holiday__c> at line 7 column 32. Here is my code:

 

trigger createHoliday on Leave_Request__c (after insert) {
    List<LR_and_Holiday__c> lrholidaylist = new List<LR_and_Holiday__c>();
    List<Holiday__c> allHoliday=[SELECT ID FROM Holiday__c Where Holiday__c.Holiday_Start_Date__c > Today];
    for(Leave_Request__c insertLR : Trigger.new){
        LR_and_Holiday__c lrholiday = new LR_and_Holiday__c();
        lrholiday.Leave_Request__c = insertLR.ID;
        lrholiday.Holiday__c = allholiday.ID;
        lrholidaylist.add(lrholiday);
    }
    Database.insert(lrholidaylist);
}

 Please help. 

 

Thank you. 

Hello,

 

I need assistance in the creation of a trigger that will not allow the deletion of an Opportunity under the following circumstances:

 

  • If there is an Agreement Name (Name) (echosign_dev1__SIGN_Agreement__c is object)
  • Or if there is a Sales Order No (Name) (Sales_Order__c is object)
  • Or if there is an Sales Invoice No (Name) (Sales_Invoice__c is the object)
  • Or if there is an attachment present in the Agreement

 

Thank you for your help.

 

Regards,

Alex

Hello,

 

I am trying to create a button that sits on the OpportunityLineItem related list on Opportunities that will create a new Price Plan record for each line item it finds. In theory this doesn't sound too hard but I keep getting an error "identifier starts immediately after numerical literal" and I can't figure out what is causing this error. I don;t see anything wrong with my syntax

 

{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.OpportunityLineItem)};
var newRecords = []; 

if (records[0] == null) 
{ 
    alert("Please select at least one row");
} 
else 
{
    var oppLineItemRec = sforce.connection.query("select Product2,UnitPrice,Quantity from OpportunityLineItem where id in ('"+ records +"')");

    for (var n=0; n < oppLineItemRec.length; n++) { 
        var c = new sforce.SObject("Price_Plan__c");
        c.Product__c = oppLineItemRec[n].Product2; 
        c.List_Price__c = oppLineItemRec[n].UnitPrice;
        c.Quantity__c = oppLineItemRec[n].Quantity; 
        c.Account__c = {!Opportunity.AccountId};
        c.Opportunity__c = {!Opportunity.Id};
        newRecords.push(c);
    }
}

var result = sforce.connection.create(newRecords); 

window.location.reload();

 Does anyone know what this error could be caused by?

Thanks

Mark

Hi All,

 

I have created a Custom Object within my Org, and I would like to have a Custom Button which, depending on the User's Role, will take them to one of three Report Folders, to view a selection of reports related to this Object.

 

I have used the following foruma, which saves without a problem, and when you check the Syntax returns no errors:

 

if ( 
{!$UserRole.Name} = "Central TM" || "Eastern TM" || "Ireland TM" || "Northern TM" || "South Central TM" || "South East TM" || "South West TM", 

"https://emea.salesforce.com/00l20000001nVUx", 

if ( 

{!$UserRole.Name} = "Central RBM" || "Eastern RBM" || "Ireland RBM" || "Northern RBM" || "South Central RBM" || "South East RBM" || "South West RBM", 

"https://emea.salesforce.com/00l20000001nVUs", 

"https://emea.salesforce.com/00l20000001nVV2" 

))

However, whenever I test the code it does not work - it comes back with an error message:

 

"URL No Longer Exists"

 

Moreover, if I copy+paste any one of the 3 URLs I have used in the above formula, it takes me to exactly the right place, so I know that the URLs are fine.

 

Can anyone let me know what is going wrong please?

 

Additionally (just a by-the-by if anyone can help), I can only seem to show this custom button within one of the List Views (which has to be selected after a user has navigated to my Custom Object tab) - is there any way for the button to be visible as soon as a user clicks on the Custom Object tab, without them having to select a List View first?

 

Thank you for any help you can provide,

 

Andy

Hello,

 

I need assistance in the creation of a trigger that will not allow the deletion of an Opportunity under the following circumstances:

 

  • If there is an Agreement Name (Name) (echosign_dev1__SIGN_Agreement__c is object)
  • Or if there is a Sales Order No (Name) (Sales_Order__c is object)
  • Or if there is an Sales Invoice No (Name) (Sales_Invoice__c is the object)
  • Or if there is a Google doc, note or attachment present in the Opp

Thank you for your help.

 

Regards,

Alex

 

Hi Friends,

 

I need detailed information about the creation of Sites in SFDC. In Sites, Login functionality is mandatory.

 

can we develop sites with out login credentials?

 

I developed site : AppSetup -> Develop -> Sites and click New and i gave the all the required details and click on the Save button.

 

Now, i want to use how to use this site and want to assign the developed pages to it.

 

Please proivde me detailed documentation about the creation of Sites.

 

Thanks in advance.

 

Regards,

Phanikumar

Does anyone have experience with required custom fields on Web2Lead forms?

Our web form contains the following onSubmit validation:  


<form onSubmit="MM_validateForm('first_name','','R','last_name','','R','email','','RisEmail','phone','','R','company','','R');return document.MM_returnValue" method="post" action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8">

I would like to also add some custom fields to that list, but it seems like I need to add the field id (00N800000054JbO) which creates ridiculous-looking error messages for the user ("00N800000054JbO is required" instead of "Product Name is required"). If I put anything other than the id in the validateForm, the Lead is created but without data from any of the required fields.
Any suggestions/workarounds/3rd party extensions would be greatly appreciated.
thanks,
Leif
  • March 27, 2012
  • Like
  • 0

 

Hello,

 

Managed Package Functionality:


I am developing on managed package app which will be used by different customer.In this app, I am using one object called Job. I need to use one field as Job Number. This Job Number field is populated based on Customer's demand.

 

For example,
Customer 1 has requirement to populate it as YYYY_MM_AutonumberValue.

 

Customer 2 has requirement to populate it as MM_YYYY_AutonumberValue.

 

Customer 3 has requirement to populate it as only AutonumberValue.

 

Customer needs to have ability to to provide different criteria to set this value.

 

I also want to use this field on visualforce pages, apex code.

 

What would be suggestion to handle such scenarios?

 

 

Thanks,
Devendra

Is there a way to render a visual force page using a Word template?

Hello,

 

I have a mobile app that ties into the salesforce fields, which the mobile will update certain salesforce fields.

 

Can I use the after update trigger based on those changes? If so, please advise on how to proceed.

 

or does the trigger only activate when a salesforce user goes "edit/save"

 

Cheers,

davidjbb

Hi,

 

We got a requirement to pull the records which contains '123' in a particular column. So, we used LIKE '123%' clause in the query. However, the search text value will be entered dynamically and hence we tried to change the query with class varibale for the search text. But it fails for the below where clause.

 

LIKE "'"+searchText+"%'"

 

Can anyone help me to fix this issue.

 

Regards,

SuBaa

  • March 21, 2012
  • Like
  • 0

I want to implement a use case like this:

 

1. System allows a user to send an email to a client. User is prompted for a to: address, subject and body text.

2. There is an input file field and a button labelled "Upload" which allows a user to browse for a file to upload which will be attached to the email. The user is allows to repeat this step multiple times to upload multiple attachments.

3. Each time a file is uploaded, the page is refreshed and a table at the bottom of the screen lists the file names of all the files uploaded so far.

4. User can click on the file names of the uploaded files shown in the table. A new window opens with a preview of the uploaded file

5. The user can finally click the "Send" button on the form which will send the email along with all attachments uploaded.

6. The user can close the send email window at any time. If they do so, any files uploaded during the session are deleted from memory.

 

Is something like this even possible? I have been doing a lot of research on using the messaging.singleemailmessage class and can't find any examples remotely like what I want to achieve.

 

I can't get my head around where the uploaded attachments would be stored temporarily which the user is composing the email.

 

According to what I read, an attachment must have a "Parent ID". Thus, if I coded it to put the attachments uploaded against my custom object, what happens if the user aborts the email send operation? The files will still exist against the object. How would I get the system to automatically delete the files if the user aborts?

  • March 21, 2012
  • Like
  • 0

Good morning.

 

I need to implement a solution in my company but do not know if you can perform this task.

I need to delete a value in ALL the opportunities created inside my base. But this taskmust be performed only ONCE.

This can be done?

If yes. How can I make it?

I appreciate the answers.

 

When generating quotes, the first field is Company Address.  Can this be renamed to just Address?  I can't seem to find it under the Tab Names & Labels.  

 

order form screenshot

Hi,

 

I'm very  much new to apex and salesforce...has been only few days..Have little knowledge in programming..
kind of stuck writting my first trigger.Please can anyone help..

 

I'm writting a trigger that updates every accounts Account.Master_Score__c ..it searches all its contacts score_card__c field ..gets the max value present and updates..I have made the code very complex...now getting error in last line of code..pls help me completing

error: initial term of field expression must be concrete Sobject : list<id>

 

 

 

trigger trigger_new on Contact (after insert, after update)
{
List<Id> contlist = new List<Id>();
List<Id> contlist1 = new List<Id>();
    List<Id> contlist4 = new List<Id>();
    
Map<Id, Contact>newmap= new Map<Id, Contact>();

     for (Contact c : trigger.new)
    {
     while( c.score_card__c >0 )
   {
        contlist.add(c.id);
        for(contact ca : contlist)
         {
             if(ca.Account.Id=Account.id)
            {
                   contlist1.add(ca.id);
                        List<contact> contlist2=[select id,score_card__c from contact where id in : contlist1];
                        for(contact c2: contlist2)
                      {
                             for(Integer i=0;i<=contlist2.size();i++)
                             {
                                 List<AggregateResult> contlist3=[select MAX(score_card__c) from contact where id in : contlist2];
                                    contlist4.add(c2.id);
                                 c2.Account.Master_Score__c= contlist4.score_card__c;
                                 
                             }
                  
                       }
                  
          
                    
              }
    }
       
   }
     
 }
}

 

 

 

 

 

trigger test1 on Lead (after insert)
{
    
     Set<ID> ls = new Set<ID> ();
     for(Lead l:Trigger.new)
    {
        ls.add(l.id);  
    }
    
    List<Lead> lis=[Select Id,Name, Status,Email,Company,fax,from Lead where id in:ls];
       List<Contact> con=[Select Id,Name ,Email_2__c,fax from Contact ];
       List<Contact> lstContact = new List<Contact>();

          
       
   
       for(Lead ld:lis)
       {
           for(Contact cn:con)
           {
              
                   
                   Contact objC= new Contact();    
                objC.FirstName=ld.FirstName;
                objC.LastName=ld.LastName;
                lstContact.add(objC);
 
           }    
               customobj.lookupfield=objC.Id;//Here i am getting nothing ie id is null here...can u pl help        }
           
           if(lstContact.size() > 0 )
        insert lstContact;
      
                   
}

 

i am getting nothing ie id is null here...can u pl help..i want to get the recently created id there..did you understand what i am asking for...thanks for replying....:)

 how  to reference contact id of the record which is inserted when the lead is created....


trigger test on Lead (after insert)
{

Set<ID> ls = new Set<ID> ();
for(Lead l:Trigger.new)
{
 ls.add(l.id);
}

List <Lead> lis=[Select Id,Name,Status,Email,Company,fax,FirstName,LastName from Lead where id in:ls];
List<Contact> con=[Select Id,Name ,Email_2__c,fax from Contact ];
List<Contact> lstContact = new List<Contact>();
//List<Contact> cntem=[Select Id,Email_2__c from Contact where Email_2__c=:lis.Email];


for(Lead ld:lis)
{
for(Contact cn:con)
{
if(ld.Email==cn.Email_2__c)
{

//Trigger.new[0].addError('Email already exists');
}

else if(ld.Email != cn.Email_2__c)
{



Contact objC= new Contact();
objC.FirstName=ld.FirstName;
objC.LastName=ld.LastName;
objC.RecordTypeName__c='Candidates';
lstContact.add(objC);

}

if(lstContact.size() > 0 )
insert lstContact;

}

 My problem is when i insert a lead...2 contacts are inserted instead of one...can some tell me why this is happening...pl help...

We want to access salesforce.com ISV partner program to launch new product on appexchange market.

 

So we register as ISV partner on http://www.salesforce.com/partners/join/  and filled all necessary details .

But we didnt receive anything from salesforce for Partner program activation.

 

Please let us know how much time is required to get partner program activation. Also how to follow up with request.

Is there any way to check status of our application.

 

Any help will be greatly appreciated.

 

Regards,

bForce

Hello Guys,

 

We are having one huge class , which is around 1500 lines of code in it and contains only one method.

now when we are trying to add any new code in methhod it shows compile error as below 

 

Compile Error : Method exceeds maximum number of allowed op codes, please break this method into multiple ,smaller methods.

 

 

 

Does is there any limit for code length in class function.

 

 

Any help will be apritiated .

 

Thanks,

Bala

 

Hi All,

I am trying to call Solbright Webservice using http callout method,

 

But suddenlly it started throwing exception like below.

 


System.CalloutException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed

 


Same apex code was working fine previously , also there is no any code change or configuration change from Salesforce site.

 

Please let me know if anybody across same scenario

 

Thanks ,

Bala

Hi, Is there any way on community , so I can change display name of my community account. Thanks in advance, Bala

Guys,

 

I am getting following exception

 

System.LimitException: Apex CPU time limit exceeded

Class.MailManager.IsTestPassed: line 142, column 1 Class.MailManager.SearchEmailTemplates: line 56, column 4 External entry point

 

 

I tried to handle same with try catch,

 

But there is no luck

 

Does anybody came across such exception ???

 

Any help on this will be great

 

Cheers,

Bala

Hi all,

Anybody please tell me how do I add local images /snapshots to post ?

Is there anything I am missing :::::

 

Thanks,

Bala

Hell All,

Is it possible to define trigger on  OpportunityTeamMember ?

Thanks in advance ...

 

Thanks,

Bala

Guys,

 

I came across this issue with Mozila ,

When I click on CreatePdf button on Quote record [Standard button]

 

Some time it get crashed.

 

If any body came across such scenario.

 

Thanks,

Bala 

 

Guys,

I want to show one Modal Dioloug box (Based on certain conditions) when Any user  login to salesforce Org using Standard Login Page

Bussiness need some thing like that

1) User goes to login.salesforce.com link and enter creditials

2) We want to Show some Modal Dioloug  box like Accept Terms and Conditions  , If he agree then we want to redirect him to INSIDE

ELSE

redirect to /logout.jsp

 

I tried following Approach

Load a frame [Visual force page ] on Home page component and show some modal box,

But it takes some time to load the frame after login (few seconds....)

Inbetween If user click else where (like any Tab ) then he will enter in side the system

 

Please let me know if any other approach for it,

 

 

Thanks in Advance,

Bala

 

 

Hi,

 

I am using lead Standard page layout,

 

Lead record has a Activity History as related List,

 

Now I  want to insert my visual force page in place of related list , Is it possible??

 

In Simple words "Overiding related list with custom VF page in Standard page Layout"

 

Thanks In Advance,

Bala

My requirement is as follow

 

I have a Visual force page with some input fields

It has a lookup field

When user click on Search icon ------Standard Search popup opened -------- User select some record

and return back to original page

when it returns to original page I want to retrive some data from selected master record and populate on the page 

Please help me how to catch this event in javascript or apex....

 

code is as follow

 

 

<apex:pageBlockSection id="GeneralInfo" columns="1" showHeader="true" title="General Information for Claims"> 
<apex:inputField Value="{!Claim__c.Name}"/>
<apex:inputField Value="{!Claim__c.Description__c}"/>
<apex:inputField Value="{!Claim__c.RequestedAmount__c}"/>
<apex:inputField Value="{!Claim__c.Fund_Request__c}"  onchange="changed()" onselect="selected()" onmouseout="mouseout()" onblur="alert('onblurred');"/>
</apex:pageBlockSection>

 

 

If we capture this event, then We can populate fields using ajax :)

 

Thanks in advance,

Bala

 

  • September 23, 2010
  • Like
  • 0

Is it possible to add new custom field in chatter object?

if yes please tell me how we should go for that ...

 

Thanks in advance,

Bala

I am not getting any error but it doen't creat any task we create or update account record.

 

trigger CreateFlowupTask on Account (after insert,after update) {

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

   for (Account a : Trigger.new) {
   
   task t = new task ();
   t.ActivityDate = a.ship_date__c; // and so on so forth untill you map all the fields.
   t.Subject = 'please call me';
   t.OwnerId = a.OwnerId;
   t.WhatId = a.id;
   taskToInsert.add(t);
}
}

I was wondering if something like this is possible through S controls and a JS button?

 

The attachment would need to be on the Service_Request__c object, but the Id for the visualforce page references a different object (Proposal__c)

 

I'm getting the error (Expected ';' ) and I can't tell where i'm going wrong...

 

{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
sforce.connection.serverUrl = '{!$Site.Prefix}/services/Soap/u/24.0';

try {
	var strQuery="Select Id from Proposal__c where Status__c = 'Awarded' and Service_Request__c = '"+'{!Proposal__c.Service_RequestId__c}'+"'";
	var LoeID = sforce.connection.query(strQuery);
	PageReference savePDF = new PageReference('/apex/vendorloe?rfpId='+LoeID);
	Blob pdfBlob = savePDF.getContent();
	var thisOb = new sforce.SObject("Service_Request__c");
		thisOb.Id = "{!Service_Request__c.Id}";
	var Atch = new sforce.SObject("Attachment");
		Atch.ParentId = thisOb.Id;
		Atch.Name = 'Letter of Engagement'+'.pdf'; 
		Atch.ContentType = 'pdf';
		ATch.Body = pdfBlob;
	
	result = sforce.connection.insert([Atch]);
} 
catch(er) {
	alert(er);
}

 

 

 

  • May 17, 2012
  • Like
  • 0

Hi,

 

I have created a button on a custom object  called "PERFORMACTION". (I went to the list view  of Search layouts and added a custom button for a custom object)

Once I click on "Go" on the custom object I will get the "PERFORMACTION" button.Then my logic goes.

 

Once the process happens there I want to return back to previous page where I clicked "PERFORMACTION" button.

 

(I tried the below code

" <apex:page action="{!URLFOR($Action.Equip__c.List, $ObjectType.Equip__c)}"/> "  

but it goes only to the custom object's home page, I need automatically go to the next page. I mean the page after clicking "Go" button on the custom object page)

 

Please let me know how to do this?

 

Thanks,

JBabu.

 

 

  • April 26, 2012
  • Like
  • 0

Hi there

 

WOrking on a custom object and was trying to add a Record Type to the object.

 

On the screen there is this paragraph:  "Select the Enable for Profile checkbox to make the new record type available to a profile. Users assigned to this profile will be able to create records of this record type, or assign this record type to existing records. To make the new record type the default for a profile, select the Make Default checkbox."

 

However, the Make Default checkboxes aren't even enabled.  Is it because this is the very first Record Type I'm adding to my custom object?  If so then all profiles will have to have that as the default record type?  

 

Under what condition will I be able to see the "Make Default" checkboxes enabled?  I don't know if I'm missing something here.  

 

I'm using the System Adm profile.

 

Thanks a lot!

 

 

 

Can named portal users use a javascript onclick button? I'm getting a cryptic error message from the customer portal side - but i've tested and the button works for internal users.

 

The profile has API enabled, and i've tried combinations of API only User, Portal Super User to no avail.

 

The error: 

 

Remote invocation failed, due to: (Lots of html markup,seems like my generic error page)

then...

Page Not Found: /portal/services/Soap/u/24.0

  • April 24, 2012
  • Like
  • 0

Hello everyone,

 

 

I'ld like to restrict the lead conversion when the user is not the lead owner. What's the easiest way?

 

 

Thanks in advance

 

Javier Jiménez

Abante Asesores

  • April 24, 2012
  • Like
  • 0

Is it possible to update multiple records from a detail page button with the help of a query? I know it's possible to do this with a list, but here's the scenario:

 

User recommends child record - changes a status and a boolean. Other child records also need to have their boolean(s) toggled to true. However, the button is on the detail page - NOT a list. 

 

The following works great:

 

{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")}

var newRecords = [];

var thisP = new sforce.SObject("Proposal__c");
thisP.id = "{!Proposal__c.Id}";
thisP.Status__c = "Awarded";
thisP.test__c = true;
newRecords.push(thisP);

result = sforce.connection.update(newRecords);

location.reload(true);

 

 

However, I'm trying to introduce this, where Ideally i'd like to update other child records (with the same parent (Order__c) lookup)

 

{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")}

var newRecords = [];

var otherP = sforce.connection.query("Select Id from Proposal__c where Order__c = '{!Proposal__c.OrderId__c}'  ");
otherP.test__c = true;
newRecords.push(otherP);  //Add all other records to array?

var thisP = new sforce.SObject("Proposal__c");
thisP.id = "{!Proposal__c.Id}";
thisP.Status__c = "Awarded";
thisP.test__c = true;
newRecords.push(thisP);   //Add current detail page record to array

result = sforce.connection.update(newRecords);

location.reload(true);

 

  • April 23, 2012
  • Like
  • 0

How would I sort AllOpenTasks and AllCompletedTasks ascending by ActivityDate?

 

AccountExt Class:

public class AccountExt {

    public AccountExt(ApexPages.StandardController controller) {
    acc = (Account) controller.getRecord();
    }
    private final Account acc;
    Set<id> AccountIds = new set<ID>();
    
    public void AccountIds(){
    	AccountIds.add(acc.Id);
        for(integer i=0;i<5;i++){
            for(Account a: [select Id from Account where ParentId in :AccountIds limit 45000])
            AccountIds.add(a.Id);
        }
    }
    
    public list<Contact> getAllContacts(){ 
        if(AccountIds.size()==0) AccountIds();
        return [select Name, Title, Account.Name, Phone, Email from Contact where AccountId in :AccountIds];
        }
	public list<Task> getAllOpenTasks(){ 
        if(AccountIds.size()==0) AccountIds();
        list<Task> tasks = [select Id, Subject, Type, Call_Notes__c, Account.Name, WhoID, ActivityDate, OwnerId from Task where AccountId in :AccountIds and IsClosed = False];
        return tasks;
        }
    public list<Task> getAllCompletedTasks(){ 
        if(AccountIds.size()==0) AccountIds();
        list<Task> tasks = [select Subject, Type, Call_Notes__c, Account.Name, WhoId, ActivityDate, OwnerId, Id from Task where AccountId in :AccountIds and Isclosed = true];
        return tasks;
        }
}

 

AllOpenTasks Visualforce Page:

<apex:page standardController="Account" extensions="AccountExt" sidebar="false" showHeader="false">
    <script>
      function doRedirect()
      {
       window.parent.location.href = '{!URLFOR($Action.Task.NewTask)}';
     }
    </script>
    <apex:form >
    <apex:pageBlock title="Open Tasks">
        <apex:pageBlockButtons location="top">
            <apex:commandbutton onClick="doRedirect()" value="New Task"/>
        </apex:pageBlockButtons>
        <apex:pageBlockTable value="{!AllOpenTasks}" var="item">
            <apex:column headervalue="Subject">
                <apex:outputLink value="/{!item.Id}" target="_parent"><apex:outputField value="{!item.Subject}" /></apex:outputLink>
            </apex:column>
            <apex:column value="{!item.Type}" />
            <apex:column value="{!item.Call_Notes__c}" />
            <apex:column value="{!item.Account.Name}" />            
            <apex:column value="{!item.WhoId}" />
            <apex:column value="{!item.ActivityDate}" />
            <apex:column value="{!item.OwnerId}" />
        </apex:pageBlockTable>
    </apex:pageBlock>  
    </apex:form>
</apex:page>

 

AllCompletedTasks VisualForce Page:

<apex:page standardController="Account" extensions="AccountExt" sidebar="false" showHeader="false">
    <script>
      function doRedirect()
      {
       window.parent.location.href = '{!URLFOR($Action.Task.NewTask)}';
     }
    </script>
    <apex:form >
    <apex:pageBlock title="Open Tasks">
        <apex:pageBlockButtons location="top">
            <apex:commandbutton onClick="doRedirect()" value="New Task"/>
        </apex:pageBlockButtons>
        <apex:pageBlockTable value="{!AllOpenTasks}" var="item">
            <apex:column headervalue="Subject">
                <apex:outputLink value="/{!item.Id}" target="_parent"><apex:outputField value="{!item.Subject}" /></apex:outputLink>
            </apex:column>
            <apex:column value="{!item.Type}" />
            <apex:column value="{!item.Call_Notes__c}" />
            <apex:column value="{!item.Account.Name}" />            
            <apex:column value="{!item.WhoId}" />
            <apex:column value="{!item.ActivityDate}" />
            <apex:column value="{!item.OwnerId}" />
        </apex:pageBlockTable>
    </apex:pageBlock>  
    </apex:form>
</apex:page>

 

Hi,

 

On the Home page, to the top right corner there is a button link "Discover Spring 12" found. One of my client's requirement is to remove that button on the home page. We tried to remove that button but no solution could be found. Can we remove it? Please let us know the solution if any .

 

Thanks,

Pavan

 

 

Is it possible to write a trigger that when an owner of a contact is change, the account owner is updated to the same owner as the contact? Also, if the account has multiple contacts associated with it, will the other contacts ownership be transferred as well? Any advice or tips would be much appreciated.

Hi, 

 

I am trying to create a junction object between two custom objects. I keep getting this error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Holiday__c> at line 7 column 32. Here is my code:

 

trigger createHoliday on Leave_Request__c (after insert) {
    List<LR_and_Holiday__c> lrholidaylist = new List<LR_and_Holiday__c>();
    List<Holiday__c> allHoliday=[SELECT ID FROM Holiday__c Where Holiday__c.Holiday_Start_Date__c > Today];
    for(Leave_Request__c insertLR : Trigger.new){
        LR_and_Holiday__c lrholiday = new LR_and_Holiday__c();
        lrholiday.Leave_Request__c = insertLR.ID;
        lrholiday.Holiday__c = allholiday.ID;
        lrholidaylist.add(lrholiday);
    }
    Database.insert(lrholidaylist);
}

 Please help. 

 

Thank you. 

Hello,

 

I need assistance in the creation of a trigger that will not allow the deletion of an Opportunity under the following circumstances:

 

  • If there is an Agreement Name (Name) (echosign_dev1__SIGN_Agreement__c is object)
  • Or if there is a Sales Order No (Name) (Sales_Order__c is object)
  • Or if there is an Sales Invoice No (Name) (Sales_Invoice__c is the object)
  • Or if there is an attachment present in the Agreement

 

Thank you for your help.

 

Regards,

Alex

Hello,

 

I am trying to create a button that sits on the OpportunityLineItem related list on Opportunities that will create a new Price Plan record for each line item it finds. In theory this doesn't sound too hard but I keep getting an error "identifier starts immediately after numerical literal" and I can't figure out what is causing this error. I don;t see anything wrong with my syntax

 

{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
var records = {!GETRECORDIDS($ObjectType.OpportunityLineItem)};
var newRecords = []; 

if (records[0] == null) 
{ 
    alert("Please select at least one row");
} 
else 
{
    var oppLineItemRec = sforce.connection.query("select Product2,UnitPrice,Quantity from OpportunityLineItem where id in ('"+ records +"')");

    for (var n=0; n < oppLineItemRec.length; n++) { 
        var c = new sforce.SObject("Price_Plan__c");
        c.Product__c = oppLineItemRec[n].Product2; 
        c.List_Price__c = oppLineItemRec[n].UnitPrice;
        c.Quantity__c = oppLineItemRec[n].Quantity; 
        c.Account__c = {!Opportunity.AccountId};
        c.Opportunity__c = {!Opportunity.Id};
        newRecords.push(c);
    }
}

var result = sforce.connection.create(newRecords); 

window.location.reload();

 Does anyone know what this error could be caused by?

Thanks

Mark