• gokul bharati
  • NEWBIE
  • 140 Points
  • Member since 2014

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 14
    Replies
I want to create a trigger which will validate the user role. Which means if role of new user is equals to its manager's role and new user's role id and its manager's roleid don't have a parent child relationship then it will show an exception. If any one hv success in same plz help..
I need help on showing list of user licences in Visualforce Page. Is this possible? If yes, please send me the steps to follow.
Once the user saves the record, it must be saved as pdf and it should be mailed as an attachment to the record owner.
Hello everyone,

I'm configuring Salesforce for a non-profit and I'm using Salesforce enterprise with the Non-Profit Starter Pack. We're linking our opportunities object to both contacts and accounts/households and we want our users to be able to, when filling up the opportunity form, select the contact that made the donation from a custom contact lookup field (Contact_Name__c) and upon creating the record the standard Account lookup field will be filled up with this contact's account/household name automatically. This way our users won't have to manually fill in both the contact and account fields for every opportunity record they wish to create.

This is the current trigger iteration I'm using:

trigger UpdateRegistrationHousehold on Opportunity (before insert, before update) 
{   
    for (Opportunity a:trigger.new)
    {
        if(a.recordtypeID == '012o0000000NnqM')   
        {a.Account.Name = a.Contact_Name__r.Account.Name;}
    }    
}

We want to implement this functionality only on a particular opportunity record type.

This particular code structure has worked for me when updating other fields prior to this, but for this specific issue it's been yielding errors and driving me nuts. I've been tweaking this bit of code a bit and depending on my tweaks, 1 of two things seems to happen: either the Account field remains unpopulated, or the form doesn't save and I get this error: Error:Apex trigger UpdateRegistrationHousehold caused an unexpected exception, contact your administrator: UpdateRegistrationHousehold: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.UpdateRegistrationHousehold: line 6, column 1

I have limited coding knowledge so I'm looking forward to hearing from you guys and learning more in the process! Cheers! :)



 
Hi all,

is there a way to have a limit on the amount of times a value in a picklist field can be selected? I have an object called Software_Assets__c and a vaule in a picklist called Microsoft Office. 

I want the Microsoft Office value to only be selected 10 times.

Many thanks

Hello,

I am trying to use Continuation for the first time and am hitting a strange error. Below is a simple page I created with both a Synchronous Callout and a Continuation Callout button. When, in my developer org, I press the "Synchronous Callout" button, I get a response as expected. When I press the "Continuation Callout" button I get an error, "Apex class 'ApexPage.ContinuationController' does not exist". Have you seen this? Do I not understand Continuation?

Page:

<apex:page controller="ContinuationController" showChat="false" showHeader="false" sidebar="false" id="pg">
	<apex:pageMessages id="frmMsgs"/>	
	<apex:form id="pgFrm" >
		<apex:commandButton action="{!testSyncCallout}" value="Synchronous Callout" reRender="frmMsgs"/>
		<apex:commandButton action="{!testContinuationCall}" value="Continuation Callout" reRender="frmMsgs"/>
	</apex:form>	
</apex:page>
 

Controller:

public with sharing class ContinuationController {
	
    private String returnedContinuationId;
    private String baseSericeURL = '<Im not telling you my url!>';

	public ContinuationController() {}

	public void testSyncCallout() {
        HttpResponse testResponse = new HttpResponse();
        HttpRequest testRequest = new HttpRequest();
        HTTP HTTPService = new HTTP();
        testRequest.setMethod('GET');
        testRequest.setEndpoint(baseSericeURL);
        testRequest.setTimeout(60000);
        testResponse = HTTPService.send( testRequest );
        ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.INFO,  testResponse.getStatusCode() + ': ' + testResponse.getStatus() + ' '+ testResponse.getBody()) );
    }

    public Object testContinuationCall() {
        //Timeout in seconds, 60 is limit
        Continuation con = new Continuation(60);
        //Set callback method
        con.continuationMethod='testContinuationCallback';
        //Create callout request
        HttpRequest req = new HttpRequest();
        req.setMethod('GET');
        req.setEndpoint(baseSericeURL);
        returnedContinuationId = con.addHttpRequest(req);
        return con;
    }

    public Object testContinuationCallback() {
        //Get the response by using the unique label
        HttpResponse httpRes = Continuation.getResponse(returnedContinuationId);
        ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.INFO,  httpRes.getStatusCode() + ': ' + httpRes.getStatus() + ' '+ httpRes.getBody()) );
        //Return null to re-render the original Visualforce page
        return null;
    }
}


Error Message:
User-added image

<apex:repeat value="{!pages}" var="page">
      <apex:commandlink value="{!page}" action="{!displayPage}">
      <apex:param value="page" name="number" assignTo="{!pageNumber}"/>
      </apex:commandLink>&nbsp;&nbsp;
  </apex:repeat>
Here i am displaying commandlinks 1 2 3 ......when i click on the link respective number will pass to controller..is it possible....?
Thanks in advance 
Hi All,
  public void savemethod(){
  acc.name='cname';
  acc.annualrevenue='2123';
  acc.RecordtypeId='001K0000012C7C2';// here id is account1 record type id
  insert acc;
}
above method succussful inserting Record but when i click details of Record it is inserting another Recordtype is name 'account2'
account2 recordtype is defualt record type for profile...
How to solve it please any one can tell me...!

Thanks
NNR
 
  • November 29, 2014
  • Like
  • 0
Hi,

I have created a custom field on User i.e. My_Team__c . So I want to create a trigger on- when create or update a user its manager,s My Team will be automaticall updated with new created user Name and its subusers.. So if any one know how to do please help.
I want to create a trigger which will validate the user role. Which means if role of new user is equals to its manager's role and new user's role id and its manager's roleid don't have a parent child relationship then it will show an exception. If any one hv success in same plz help..
I need help on showing list of user licences in Visualforce Page. Is this possible? If yes, please send me the steps to follow.
Once the user saves the record, it must be saved as pdf and it should be mailed as an attachment to the record owner.
I can't believe no one out there has wanted to do this but I've searched and searched and haven't found anything similar.  Specifically when converting a lead with an opportunity we'd like it to immedietly go to the add product page for the opportunity or at least just the page for the opportunity that was just created.  It seems like there should be some way to do this.  Something must tell it that it was just at the lead page and is now at the account page even if it's an existing account.  I just can't find how.  If anyone has any ideas on this I would love to hear them.

Thanks,
Amanda
Hi everyone,

I have a Case where I need to control the number of users created for customer portal with respect to ech account.

For example: I have Account A under which I have contacts 1,2,3,4,5. out of the five contacts the Administrator or delegated administrator should have the ability to limit the number of users can be created from each contact.

Is it possible to create a picklist field in the accounts objects with the values  like 1 2 3 ttc and based on the selection is it possible to limit the number of users created for each account?

Idea to Implement trigger is appreciated
In a pageblock table, I have this column which passes the value entered in the inputField to controller for rerendering
as outputtext. However, the following code is returning the null value in counting field. Can anyone help in this regard.


<apex:column headerValue="Capacity" id="CapacityColumn">
         <apex:inputField id="cap" value="{!fest.Capacity__c}"  rendered="{!isEditable}" />
         <apex:actionSupport event="onclick"                               
                                rerender="counting" status="counterStatus">
          <apex:param assignTo="{!counting}" value="this.value" />
          </apex:actionSupport>
         </apex:column>
  ------ --------
output2: <apex:outputtext id="counting"  value="{!Counting}"/>
 

Controller:
String Counting;
public String getCounting() {      
      
        return counting;
    }
Hello everyone,

I'm configuring Salesforce for a non-profit and I'm using Salesforce enterprise with the Non-Profit Starter Pack. We're linking our opportunities object to both contacts and accounts/households and we want our users to be able to, when filling up the opportunity form, select the contact that made the donation from a custom contact lookup field (Contact_Name__c) and upon creating the record the standard Account lookup field will be filled up with this contact's account/household name automatically. This way our users won't have to manually fill in both the contact and account fields for every opportunity record they wish to create.

This is the current trigger iteration I'm using:

trigger UpdateRegistrationHousehold on Opportunity (before insert, before update) 
{   
    for (Opportunity a:trigger.new)
    {
        if(a.recordtypeID == '012o0000000NnqM')   
        {a.Account.Name = a.Contact_Name__r.Account.Name;}
    }    
}

We want to implement this functionality only on a particular opportunity record type.

This particular code structure has worked for me when updating other fields prior to this, but for this specific issue it's been yielding errors and driving me nuts. I've been tweaking this bit of code a bit and depending on my tweaks, 1 of two things seems to happen: either the Account field remains unpopulated, or the form doesn't save and I get this error: Error:Apex trigger UpdateRegistrationHousehold caused an unexpected exception, contact your administrator: UpdateRegistrationHousehold: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.UpdateRegistrationHousehold: line 6, column 1

I have limited coding knowledge so I'm looking forward to hearing from you guys and learning more in the process! Cheers! :)



 
Hi all,

is there a way to have a limit on the amount of times a value in a picklist field can be selected? I have an object called Software_Assets__c and a vaule in a picklist called Microsoft Office. 

I want the Microsoft Office value to only be selected 10 times.

Many thanks

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.

 

We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.

 

The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

 

We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.

 

The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.

 

So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.

I have a detail page button that executes Javascript on click. In the button there are multiple DML statements but I would like to set save points so if an error occurs, I can roll back the changes. Is this possible without creating webservice apex methods?