• sherod
  • NEWBIE
  • 60 Points
  • Member since 2010

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

I need help writing a trigger that will delete the values in a field at a specific time.

Basically the way it would work is that if Account field "A" is populated then delete the  the values in the Account fields B,C,D,E to 0.00 at 11:59PM.

 

Thanks!

  • August 04, 2011
  • Like
  • 0

Hi there,

 

From what i am reading, it is possible to send a pdf attachment in a visual force email template. But only if that attachment is created on the fly using merge fields. 

 

Is it possible to attach a pdf file that is stored in the Notes & Attachments object, and have that attachment sent with the visual force email template?

 

 

I really want to display a pageBlock only when ApexPages.hasErrors() is true.

 

At this stage, I can only think of putting a hasErrors boolean in my controller extension and accessing the property with 

 

<apex:pageBlock rendered="[!hasErrors}">   but can I access the ApexPages.hasErrors directly from VisualForce?

 

Am I overlooking something really obvious?

  • February 09, 2011
  • Like
  • 0

Hello all.

 

I'm experiementing with creating my own webservice classes on force.com.

 

I have created my own Apex class and marked it as a web  service.

I've generated the WSDL and created a client in Netbeans using its JAX-WS tooling.

 

I have attempted to run this web service and run into the 'missing Session ID' problem.

 

To avoid this, I have generated the Partner WSDL and created additional client stubs for the Partner client, I've then executed the login method on the Partner ID and obtained a valid session Id string.

 

My issue is now a JAX-WS issue, how do I inject this session ID into the client I use to assess my own webservice class?  I can find no method / object to do this.  There is a 'SessionHeader' class in my custom client which I can call a 'setSessionId()' method on, but I can't figure out how to inject my SessionHeader into my port/service.

 

I'm not a WS guru... so is there something I'm missing?

 

 

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication3;

import enterprise.InvalidIdFault_Exception;
import enterprise.LoginFault_Exception;
import enterprise.LoginResult;
import enterprise.UnexpectedErrorFault_Exception;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.HandlerResolver;
import javax.xml.ws.handler.PortInfo;

/**
 *
 * @author sherod
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            LoginResult r = login("xxxx", "xxxx");
   

            myMethod(r.getSessionId(),null);
        } catch (InvalidIdFault_Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnexpectedErrorFault_Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (LoginFault_Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    private static LoginResult login(java.lang.String username, java.lang.String password) throws InvalidIdFault_Exception, UnexpectedErrorFault_Exception, LoginFault_Exception {
        enterprise.SforceService service = new enterprise.SforceService();
        enterprise.Soap port = service.getSoap();
        return port.login(username, password);
    }

    private static TestData myMethod(String sessId, javaapplication3.TestData t) {
        javaapplication3.MyWebServiceService service = new javaapplication3.MyWebServiceService();

        javaapplication3.SessionHeader sh = new javaapplication3.SessionHeader();
        sh.setSessionId(sessId);
        System.out.println(sessId);  //session ID output, but where to I send 'sh'?


        javaapplication3.MyWebServicePortType port = service.getMyWebService();

        return port.myMethod(t);
    }

}

 

 

  • August 16, 2010
  • Like
  • 0

Hi,

What is the best way to store large files, or blob objects (5M-100MB) in the custom object on Database.com (not force.com)?

Is there a built in support for that or we need to integrate with external storage, like S3?

 

Thanks,

Igal

 

When redirecting to a page and passing the session as a parameter using UserInfo.getSessionId() I am getting invalid session id. This was working last week.

here is the apex code:

private String buildFP_URL()

    {
        String serverUrl = 'https://' + ApexPages.currentPage().getHeaders().get('Host') + '/services/Soap/u/15.0/' + UserInfo.getOrganizationId().substring(0, 15);
        String sessionId = UserInfo.getSessionId();
        String oName = opp.Name;
       
        String encodedOname = EncodingUtil.urlEncode(oName , 'UTF-8');
        String fpServer = 'https://sbx.fpx.com';     
        return fpServer +'/login/connect.do?destination=quote"eName=' + encodedOname+ ' Quote&SfdcOpId=' + opp.Id + '&SfdcOpName=' + encodedOname+ '&SfdcServerURL=' + serverUrl + '&SfdcSessionID=' + sessionId;
       

is there a reason why the call UserInfo.getSessionId() would not return a valid session.

Newbie Question -
 I am trying to write a trigger which creates a new task when the Contract is saved.
In the task I need to populate the Sales_Name__c field with the value from the contract field Sales_Rep_c.
I am gettin a compile error indicating an invalid foreign key relationship for c.Sales_Rep_c;

Sales_Name__c = [SELECT Name From User Where Id = : c.Sales_Rep_c.id];


If I look at the properties of the Contract field Sales_rep_c it is a reference(custom) with foreign key Sales_rep_r
The Contract field Sales_Rep_c is populated with the correct id value for the user name.

Any help is appreciated!



Hello,

 

Over the weekend, our sandbox was upgraded to Winter '12, and many of my Apex tests have failures now.

 

For instance, I have a test that tries to save a Lead without a Last Name (which should lead to an error for a required field missing).

 

My test:

 

static testMethod void testExceptionsConvertCloseNoLead() { 
  myGenHelpers gh = new myGenHelpers();
		
  Lead testLead = gh.getUptimeTestLead();
  insert testLead;
	            	
  testLead.LastName = null;
	            	
   myLeadConvertCloseExtension lcc = new myLeadConvertCloseExtension(new ApexPages.StandardController(testLead));
   lcc.save();
}

 

Last week, and still in production, this test passes successfully.  However, today, it fails.

 

The problem is in this code segment:

 

                try {
	                update this.myLead;
                } catch (DmlException e) {
                    for (Integer i = 0; i < e.getNumDml(); i++) {
				    	System.debug('myClass.save: error: ' + e.getDmlMessage(i));
                        this.myLead.addError(e.getDmlMessage(i)); 
                    }
                    return null;
                }

 

Instead the error being handled gracefully, the test just fails at the upsert.

 

Any thoughts?

Hi All,

 

I  m getting the "INVALID_SESION_ID: Invalid Session ID found in SessionHeader: Illegal Session" error for all my callout and the flex pages where i m passing session id through  UserInfo.getSessionId() from apex after winter 11 rollover 

 

Dose any one experiencing the same..???

 

Does salesforce doing any fix for this..??

 

Thanks,

Amar

 

I was wondering if this APEX trigger I’m trying to write is bigger than a bread box.   So far – I have three triggers in my organization (one of which still needs a little tweaking) that are going to save me hours and hours of work each week.  I have one last piece of automation that will be critical – but I’m having a tough time figuring out where to start.  Here’s what my process looks like – any chance anyone can take a shot?  This is a little outside of my skill set as what I've written so far has been fairly basic.

 

All of my campaigns are outbound telemarketing – customers are often part of multiple lists and, on occasion, these lists can come in within days of each other.   What I would like to do – is have a trigger that applies a "stand-off" rule of ninety days for any new leads on upsert or insert.   In other words, we don't want to call these customers back to back for different prodcuts.  So as my leads are imported – if there has been an attempt or contact in the last ninety days, the lead will be imported with the status as ‘pending’, and then will change to ‘open’ once we are outside of the ninety day window.    The 'pending' status would keep these from going into the outbound dialer.

 

There would be two objects at work here – the lead object, which would have a field called ‘Call Date’ and another field called ‘Party ID’ to match against on upsert/insert.   The other object would be the opportunity object (in the case of conversion) and would also have the same two fields to test on import.   So I need the trigger to look at the Account object, if there’s a matching party ID, check and see if the call date is null, if not, then see if the call date is > 90 days and if that is false, import as pending.    If all of those statements are true, then  move over to the opportunity object and apply the same test.

 

Then the last piece would be to have those leads that are changed to a ‘pending’ status changed back to an ‘open’ status once outside of that 90 day window based on the call date match.   I think I would have to have a field that would hold the call date from any matching object and build a time based workflow from that field.    I think I can solve for this last part, but the trigger piece is blowing my mind right now!

Hello

 

I have a case where I have a public portal VF page and I want to show an image on this page.

 

Initially I wanted to use the Attachment object (I attached the image to the object showing on the page) but when I did that I got an unauthorized access error, which I assumed is because the Attachment object is not accessible to a Guest user.

 

Same think happened if I use the Document object to store the image.

 

Can someone advise what is the right way to achieve this apart from using a Static Resource?

 

Many thanks

 

Oded

Hi all,

This method populates a pageblockTble that I have built which groups child records by their parent records. I have a simpler version of this method that works fine. However, just got the need for some new logic, and now I'm struggling. The request requires me to provide two different iists based on criteria in the Child records.  The problem is that I'm getting repeating values for each child object. For example, if there are 3 child objects then I see the group of 3 child Objects and its parent repeated 3 times in the table. I understand why this is happening. I have comments to code below to explain.

 

thanks!

 

public void makesStrategyWrappers() {
                
            theDSs = new List<DeployedStrategy__c>();
            theVFDSs = new List<DeployedStrategy__c>();//I use this variable in my VF page as a map key for grouping the child objects
            List<cAIS> cAIS1 = new List<cAIS>();  
            theWrappers = new List<cAIS>();
            theWrapperMap = new Map<Id, List<cAIS>>();
            
            String queryString = this.getStrategyQuery();
            theDSs = Database.query(queryString);
                        
            if(theDSs.size() > 0) {
                    for(DeployedStrategy__c ds : theDSs) {
                        
                        if(ds.DeployedActionItem__r.size() > 0) {
                                for(DeployedActionItems__c actI : ds.DeployedActionItem__r) {
                                        if(actI.Status__c == 'Priority' && actI.Stage__c != 'Completed' && !this.showAll) {                                        	
                                           
                                           theVFDSs.add(ds); //here is where I populate the key. The values repeat because for each child that Iterate //through it adds the same key parent value. How do I populate this with just unique ideas. I tried a set but that just seems to throw errors. 
                                            
                                            cAIS1 = theWrapperMap.get(ds.Id);
                                            
                                            if(null == cAIS1) {       
	                                            cAIS1 = new List<cAIS>();
	                                            theWrappers.add(new cAIS(actI)); 
	                                            theWrapperMap.put(ds.Id, cAIS1);                              
                                            }
                                            cAIS1.add(new cAIS(actI));
                                        }
                                        if(this.showAll){
                                            theVFDSs.add(ds);
                                            cAIS1 = theWrapperMap.get(ds.Id);
                                    
                                            if(null == cAIS1) {       
                                                    cAIS1 = new List<cAIS>();
                                                    theWrappers.add(new cAIS(actI)); 
                                                    theWrapperMap.put(ds.Id, cAIS1);                              
                                            }
                                            cAIS1.add(new cAIS(actI));
                                        }
                                }
                        }
                    }
                }            
        }

 

I need help writing a trigger that will delete the values in a field at a specific time.

Basically the way it would work is that if Account field "A" is populated then delete the  the values in the Account fields B,C,D,E to 0.00 at 11:59PM.

 

Thanks!

  • August 04, 2011
  • Like
  • 0

Hi there,

 

From what i am reading, it is possible to send a pdf attachment in a visual force email template. But only if that attachment is created on the fly using merge fields. 

 

Is it possible to attach a pdf file that is stored in the Notes & Attachments object, and have that attachment sent with the visual force email template?

 

 

 

I need a rule or code for the Phone field in Accounts that if  someone leaves out the +1 on a US number, I would like Salesforce to just put it in silently.





Currently all telephone numbers for the US  start with +1 ,then area code and local number (i.e. “(454) 565-4252”) .

 

Any Suggestions!

  • August 04, 2011
  • Like
  • 0

Hi everyone,

 

I'm pretty new to the Salesforce enviroment and even more with Visualforce pages. I'm trying to make an edit page of one of my objects but I want to customize with a button how the values will be assigned.

 

For example I have to make like a Time Allocation process where I was thinking on having two Datetime inputs one for Start and one for Exit. And that I can with a click of the Start button assign the current time to the respective Datetime field. Also being able to save it and the next time I access that objects record my Start button be Disabled and my Stop button enabled. So that I can click stop and obtain the current time on the Exit Datetime field. Something like this is what I have, which is only the fields and buttons.

 

Atleast I wanna know how and if I can obtain and assign values to inputFields, and if I can make them un editable when I want to.

 

<apex:page standardController="Time__c" showHeader="true" tabStyle="Time__c" >
  <apex:form >
  <apex:pageBlock title="Time">
    <apex:pageBlockSection columns="1">
      <apex:inputField id="tStart" value="{!Time__c.Start__c}" />
      <apex:inputField id="tFinish" value="{!Time__c.Finish__c}"/>
      <apex:inputField id="tCase" value="{!Time__c.Caso__c}" />
      <apex:commandButton action=" " value="Start"/>

      <apex:commandButton action="" value="Finish"/>

    </apex:pageBlockSection>
   
    <apex:pageBlockButtons >
      <apex:commandButton action="{!save}" value="Save"/>
      <apex:commandButton action="{!cancel}" value="Cancel" immediate="true"/>
    </apex:pageBlockButtons>
 
  </apex:pageblock>
  </apex:form>
</apex:page>

  • August 04, 2011
  • Like
  • 0

I've created a VF page to replace the standard case detail page that uses tabs to show related records from related objects (Assets, Service__c).  I would like to show the case team on it's own tab but I can't seem to get the relationship name.  Everything I try returns the dreaded "'XXXXXX' is not a valid child relationship name for entity Case".

 

My code is pretty simple:

 

		<apex:tab label="Team" name="TeamList" id="tabTeamList">
			<apex:relatedList subject="{!thisCase}" list="TeamMembers" />
		</apex:tab>	

 I used Eclipse schema browser to get to relationship name "TeamMembers", I also tried the child relationship "TeamTemplateRecords" but get the same error. 

 

I did search the forums and about the only suggestion was to ensure the related list is present on the standard detail page which I've done.

 

Does anyone know what relationship name to use?

  • August 04, 2011
  • Like
  • 0

Hi All,

 

This is praveen, I am a salesforce user, i have written some part of visualforce code shown below,

 

 

 

<apex:page standardController="Account">
<apex:form >
<script>    
if("{!$Profile.Name}".substr(0,3)=="GFO")
 {      
     alert("New GFO accounts can only be created through lead conversion.  If you need assistance creating a new account, please contact SFDCacctrequests@progress.com");   
     window.location="https://tapp0.salesforce.com/001/o";
 }
 else
 {
     window.location="https://tapp0.salesforce.com/setup/ui/recordtypeselect.jsp?ent=Account&retURL=%2F001%2Fo&save_new_url=%2F001%2Fe%3FretURL%3D%252F001%252Fo";
 }
</script>
</apex:form>
</apex:page>

 

 

 

Now the issue what i am getting is ,this visualforce page is refreshing everytime when some users runs it other than GFO. If GFO users runs this it needs to show an alert with the above mentioned message...

 

I need an urgent solution for this issue...

if any one knows please send reply...

according to the requiremnt given, we have to write a batch  job which locks the records from updating for all the users when a perticual condition is met. I have created a new recordtype and a new pagelayout in which all the fields are locked and pagelayout is assigned to new RecordType. Whenever a perticular condition becomes true, this new Recordtype is Assigned to the record.

 

problem is, the records should be locked for editing for all the users except for Administrator. i.e. Admin should be able to edit those records. how can we meet this requirement? this is Urgent, any idea?

  • August 04, 2011
  • Like
  • 0

I have 10 batch apex classes (which have related scheduler classes). The first class is triggered using the external web services and after executing the first batch, it schedules the second one after 2 minutes. In this way all the batch classes completes successfully.

The  issue is that all the batch process schedules , Executes and completes successfully but the 4th batch process  scheduler after scheduling  4th  batch apex is not automatically removed from the scheduler jobs(though it runs successfully and schedules the 5th batch). I used the “System.abortJobid” command also in the scheduler class, the command gets executed but there is no effect. Next day when we trigger the first batch again the 4th  batch which is not removed from scheduler jobs is throwing an error that” The batch is already scheduled for execution” .

 

Is there any other solution for this?

 

  • August 03, 2011
  • Like
  • 0

Hi,

 

@deprecated - New subscribers cannot see the deprecated elements, while the elements continue to function for existing subscribers an API integrations... what is the meaning for this??

 

Need detail about @deprecated, @readonly and @Future annotations , with any sample example to understand clearly..