• SFDC-SD
  • NEWBIE
  • 205 Points
  • Member since 2012

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 52
    Replies

I have created a custom object todoitem__c and iam trying to insert new record into this object using standardcontroller as shown below

 

<apex:page standardController="toDoItem__c" >
<apex:form>
<apex:pageBlock title="Save Item">
<apex:pageBlockButtons>
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="My Content Section" columns="2">
<apex:inputField value="{!toDoItem__c.name}"/>

<apex:inputField value="{!toDoItem__c.dueDate__c}"/>
<apex:inputField value="{!toDoItem__c.itemNumber__c}"/>
</apex:pageBlockSection>

</apex:pageBlock>
</apex:form>
</apex:page>

 

 

but the record is not getting inserted.

please let me know am i doing any mistake here 

 

 

thank you

I tried to write my first apex code....

 

public with sharing class HelloWorldPositionClass

{

public static void HelloWorld(position__c[] positions)

{

for(position__c[] p:positions)

{

if (p.Hello__c = null || p.Hello__c != 'world')

p.Hello__c ='World';-->Error*

}

}

}

 

Iam getting the error while saving--Save error: Initial term of field expression must be a concrete SObject: LIST<position__c>  what does it mean ? how to solve?

HI,

 

How to get current user's email ID in apex trigger? Please help.

 

 

Thanks,

Arunkumar

I have a payment object that has 2 properties amount and date. I have the following code in the Apex page and Controller that displays existing payments. I want to update amount of one payments and save it. What scode should i write in the save method to acheive this. I know i have to call update payment on the save method but i am not able to retrieve the user input from the page in my controller.

 

 

 

public with sharing class PaymentDetailsController

{    

public Decimal amount_c{get; set;}    

public Datetime date_c{get; set;}            

public PageReference save()

{        

Payment__c pc = new Payment__c();        

pc.Amount__c = amount_c;               

ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'Amount - '+ pc.Amount__c );         ApexPages.addMessage(myMsg);        

return null;    

}

List<Payment__c> payments = new List<Payment__c>();            

public PaymentDetailsController()    

{             

processLinkClick();       

}             

public void processLinkClick()

{

       payments = [SELECT Id , Payment__c.Contact__c, Amount__c, Date__c FROM Payment__c WHERE Amount__c > 0 and Payment__c.Contact__c =: ApexPages.currentPage().getParameters().get('contactid')];    

}

        

public List<Payment__c> GetPaymentDetails()   

 {       

 return payments;       

}            

}

 

 

 

<apex:page controller="PaymentDetailsController" tabStyle="Payment__c" >
<apex:form >
        <h1>{!$CurrentPage.parameters.contactid}</h1>
 
        <apex:pageBlock title="Payment Details">
<apex:pageblockSection >
<h1>Page Messages:</h1>
<apex:pageMessages showDetail="true" id="msg"/>
</apex:pageblockSection>             
            <apex:pageBlockTable value="{!PaymentDetails}" var="pd">
                <apex:column HeaderValue="Amount">
                    <apex:inputField value="{!pd.Amount__c}" id="amount_c" />
                </apex:column>               
                <apex:column headerValue="Date">
                    <apex:inputField value="{!pd.Date__c}" id="date_c"/>
                </apex:column>
            </apex:pageBlockTable>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
       
    </apex:form>
</apex:page> 

Hello,

 

I have two custom lookup fields in my Case object:  User_Contact__c (User lookup)  and Opportunity_Name__c (Opportunity lookup).  I wrote a trigger to update the User_Contact__c to the Opportunity owner ID from the  Opportunity_Name__c field.  Below is my trigger code:

 

trigger Case_OpptyAttached on Case (before insert, before update) {
    
    for (case c : trigger.new) {
    
        if (c.User_Contact__c != c.Opportunity_Name__r.OwnerId) {
        
            c.User_Contact__c = c.Opportunity_Name__r.OwnerId;
        }
    }
}

 

 

When I update the case record, the custom User lookup field is blank.  Is my apex syntax incorrect?

 

Thank you so much.

 

David

  • September 13, 2012
  • Like
  • 0

Hi

I am developing custom account merge page, is there any way I can pass account ids to a JSP by selecting accounts from the list?

https://cs8.salesforce.com/merge/accmergewizard.jsp?goNext&cid={!CID1}&cid={!CID2}&cid={!CID3}

I should be able to select only 2 accounts from list.

Right now I am able to merge two account by dynamically passing the CID1 and CID2 which works fine. My requirement is I should be able to select any of 2 accounts from the list and should be pass the selected account Ids to merge wizard.

 

Appreciate any help

 

///***************** Controller *******************///
public class AccountSearchController {
 
    //added an instance varaible for the standard controller
    private ApexPages.StandardController controller {get; set;}
    // the actual account
    public Account a;
    public Account s;
    pagereference p = null;
    
    public string current_Id {get; set;}    
    public string sid1 {get; set;}
    public string sid2 {get; set;}
            
    public List<Account> searchResults {get;set;}
    public List<QResult> QResultList{get; set;}
      
    public string BillingStreet {
    get {
        if (BillingStreet == null) BillingStreet = ''; // prefill the search box for ease of use
        return BillingStreet;
    }
    set;
    }
    
    public string BillingCity {
    get {
        if (BillingCity == null) BillingCity = ''; // prefill the search box for ease of use
        return BillingCity ;
    }
    set;
    }

    public string BillingPostalCode {
    get {
        if (BillingPostalCode == null) BillingPostalCode = ''; // prefill the search box for ease of use
        return BillingPostalCode ;
    }
    set;
    }    
    
    public string BillingState {
    get {
        if (BillingState == null) BillingState = ''; // prefill the search box for ease of use
        return BillingState;
    }
    set;
    }  
    
//Constructor            
    public AccountSearchController(ApexPages.StandardController controller) {
 
        //initialize the stanrdard controller
        this.controller = controller;
        this.a = (Account)controller.getRecord();
        system.debug('AccountRec: ' +a);
        s=[ SELECT Id,Name,BillingStreet,BillingCity,BillingState,BillingPostalCode FROM Account WHERE Id=:a.Id];
        sid1=a.Id;
        BillingStreet =s.BillingStreet;
        BillingCity=s.BillingState;
        BillingPostalCode=s.BillingPostalCode;
        BillingCity=s.BillingCity;
        BillingState=s.BillingState;
        search();
    }
 
    // fired when the search button is clicked
    public PageReference search()
    {
        if (searchResults == null) {
            searchResults = new List<Account>(); // init the list if it is null
        } else {
            searchResults.clear(); // clear out the current results if they exist
        }
         
     // Use Dynamic SOQL to find the account based on user input
        String qry = 'Select o.Id,o.Name,o.BillingStreet,o.BillingCity,o.BillingState,o.BillingPostalCode from account o Where BillingStreet LIKE \'%'+BillingStreet+'%\' AND BillingCity LIKE \'%'+BillingCity+'%\' AND BillingState LIKE \'%'+BillingState+'%\' AND BillingPostalCode LIKE \'%'+BillingPostalCode+'%\' AND Id!=\''+a.Id+'\' ORDER By o.Name';

        sid1=a.id;
        System.currentPagereference().getParameters().put(sid1,'success');
        searchResults = Database.query(qry);

        if(searchResults==null)
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'No Records Found'));
       return null;
    }
    
     public PageReference amerge()
     {  
         return null;  
     }
    
    public class QResult{        
        public account acc {get; set;}        
        public string  pid  {get; set;}
        public Boolean selected {get; set;}        
        
        //This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property. We also set the selected value to false        
        public QResult(account a) {            
        acc = a;            
        pid='';
        selected = false;        
        }    
    }
}

 

//************** VF Page        ***************************//
<apex:page standardController="Account" extensions="AccountSearchController">
    <style type="text/css">
        body {background: #F3F3EC; padding-top: 15px}
    </style>
 
    <apex:form title="Merger"  >
        <apex:pageBlock title="Accounts with same Billing Address" id="block" mode="detail">        
            <apex:pageMessages />
 
                <apex:pageBlockSection title="Search by" columns="1" id="detail"  collapsible="false">      
                    <apex:outputpanel id="thePanel" style="">       
                     <p>
                      <apex:pageblockSectionItem id="id1" labelStyle="font-weight:600" >
                        <apex:outputLabel style="font-weight:600;padding-left:0px;padding-right:80px"> Billing Street</apex:outputLabel>                                           
                      </apex:pageblockSectionItem>
                      <apex:pageblockSectionItem >                       
                         <apex:outputLabel style="font-weight:600;padding-left:35px;padding-right:120px"> Billing City     </apex:outputLabel>                                           
                      </apex:pageblockSectionItem>
                      <apex:pageblockSectionItem >
                         <apex:outputLabel style="font-weight:600;padding-left:5px;padding-right:80px"> Billing Zip Code </apex:outputLabel>                                           
                      </apex:pageblockSectionItem>
                      <apex:pageblockSectionItem >
                         <apex:outputLabel style="font-weight:600;padding-left:20px;padding-right:50px"> Billing State    </apex:outputLabel>                                                                                     
                      </apex:pageblockSectionItem>
                      </p>    
                        <apex:inputText style="padding-left:0px;padding-right:50px" id="bs" value="{!BillingStreet}"  label="Billing Street"/>                   
                        <apex:inputText style="padding-left:0px;padding-right:50px" id="bc" value="{!BillingCity}"  label="Billing City   "/>                     
                        <apex:inputText style="padding-left:0px;padding-right:50px" id="bz" value="{!BillingPostalCode}"  label="Billing Zipcode   "/>                     
                        <apex:inputText style="padding-left:0px;padding-right:50px" id="bst" value="{!BillingState}"  label="Billing State   "/>                                  
                    </apex:outputPanel>
                </apex:pageBlockSection>               
 
            <apex:pageBlockSection >
                <apex:panelGroup style="align:left" >
                    <apex:commandButton value="Search" action="{!search}" rerender="resultsBlock" status="status"/>
                </apex:panelGroup>
            </apex:pageBlockSection>

            <apex:actionStatus id="status" startText="Searching... please wait..."/>
            <apex:pageBlockSection id="resultsBlock" columns="1">
                <apex:pageBlockTable value="{!SearchResults}" var="o" rendered="{!NOT(ISNULL(SearchResults))}">

<!--    <apex:column headerValue="Key Values">  
      {!o}  
    </apex:column>  
    <apex:column headerValue="Values">  
      {!ResultMap[o]}  
    </apex:column>  -->

                    <apex:column headerValue="Name">
                        <apex:outputLink value="/{!o.Id}">{!o.Name}</apex:outputLink>
                    </apex:column>
                    <apex:column value="{!o.BillingStreet}"/>
                    <apex:column value="{!o.BillingCity}"/>
                    <apex:column value="{!o.BillingPostalCode}"/>
                    <apex:column value="{!o.BillingState}"/>
                    <apex:column >
                        <apex:commandbutton action="/merge/accmergewizard.jsp?goNext&cid={!sid1}&cid={!o.Id}" value="Merge" id="Merge" rendered="true" >                         
                        </apex:commandbutton>
                    </apex:column>                     
                </apex:pageBlockTable>
            </apex:pageBlockSection>
 
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

Is there any way I can pass Account Ids in the below link for merging account using APEX?

 

This is the link for Account Merging two accounts.

 

p = new pagereference('https://cs8.salesforce.com/merge/accmergewizard.jsp?goNext=+Next+&cid=001L0000005T4bK&cid=001L0000005T4bo')

How can I pass two cids dynamically in the above URL?

When I tried it using two variables to pass I got this result

https://cs8.salesforce.com/merge/accmergewizard.jsp?cid=001L0000005T4bK&goNext=+Next+

 

 Appreciate any help on this.

 

 How can I

 

 

 

public with sharing class IP_Authorization
{   
    private List<account> IPList;
    public List<account> CIDRList; 
    public Boolean ipFound = false;       
    private string Input_IP4{get; set;}

    public PageReference p = ApexPages.currentPage();
    public string IP_PatternV4='^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$';
    
//******************************************//    
    public pagereference VerifyIP()
    {
        Input_IP4=System.currentPageReference().getParameters().get('checkip');                              
        Boolean isValidIP = Pattern.matches(IP_PatternV4,Input_IP4); 
                                 
        if (isValidIP)                 
        {   
            integer SearchIP=0;            
            SearchIP=[SELECT COUNT() FROM account WHERE                               Static_IP_Address__c=:Input_IP4                                                           
            if( SearchIP > 0 )
            {   
                ipFound= true;                                    
            }
            else 
            {                
                ipFound=false;   
            }
        }                  
        if (ipFound) 
        {
             p.getHeaders().put('Found','200');
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, '200'));             
         }
         else    
         {
             p.getHeaders().put('NotFound','404');
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, '404'));              
         }    
        return p;
    }
}

I am receiving a IP from a client, salesforce has to verify if the IP is present in account and return back response 200 if IP

found. My TestClass runs good without any issues but when I try to access the VF page with it fails. Strange thing is it works fine in Developer Edition but it fails in Sandbox.

 

Below is my visualforce page I created to test this from controller.

 

<apex:page Controller="IP_Authorization" tabStyle="account" action="{!VerifyIP}">
<apex:pageMessages id="error"/>
</apex:page>

 

This is the error I got when I try to see the VF page.

 

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!

Error ID: 1932924520-1277 (-2086038583) 

 

 

 

public with sharing class IP_Authorization
{   
    private List<account> IPList;
    public List<account> CIDRList; 
    public Boolean ipFound = false;       
    private string Input_IP4{get; set;}

    public PageReference p = ApexPages.currentPage();
    public string IP_PatternV4='^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$';
    
//******************************************//    
    public pagereference VerifyIP()
    {
        Input_IP4=System.currentPageReference().getParameters().get('checkip');                              
        Boolean isValidIP = Pattern.matches(IP_PatternV4,Input_IP4); 
                                 
        if (isValidIP)                 
        {   
            integer SearchIP=0;            
            SearchIP=[SELECT COUNT() FROM account WHERE                               Static_IP_Address__c=:Input_IP4                                                           
            if( SearchIP > 0 )
            {   
                ipFound= true;                                    
            }
            else 
            {                
                ipFound=false;   
            }
        }                  
        if (ipFound) 
        {
             p.getHeaders().put('Found','200');
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, '200'));             
         }
         else    
         {
             p.getHeaders().put('NotFound','404');
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, '404'));              
         }    
        return p;
    }
}

I am receiving a IP from a client, salesforce has to verify if the IP is present in account and return back response 200 if IP

found. My TestClass runs good without any issues but when I try to access the VF page with it fails. Strange thing is it works fine in Developer Edition but it fails in Sandbox.

 

Below is my visualforce page I created to test this from controller.

 

<apex:page Controller="IP_Authorization" tabStyle="account" action="{!VerifyIP}">
<apex:pageMessages id="error"/>
</apex:page>

 

This is the error I got when I try to see the VF page.

 

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!

Error ID: 1932924520-1277 (-2086038583) 

 

This is how I ended up with this issue

 

I am receiving IP Address in a URL.

In APEX controller, using pagereference get I extract the IPAddress from query string.

I am verifying this IP Address and passing it to Server from where request came from.

 

This is working all fine in developer edition, but when I tried to test the same in Sandbox using a URL, system threw a error and my page kept on reloading. Any help on this is appreciated.

 

Cyclical server-side forwards detected:

 

Cyclical server-side forwards detected: /apex/validateip?checkip=123.4.56.78&core.apexpages.devmode.url=1

 

 

Guys...

 

Has any body faced this issue?

 

integer exponent2 = 2^8;
system.debug('Exponent ' +exponent2);

 

Output is:

10 (Actual value should be 256)

 

 

As per Salesforce Manual:

Math Operator ^  Raises a number to a power of a specified number.

 

Folks,

 

I am looking for a working REGEX to validate IPv6. Any help on this is much appreciated.

  • September 28, 2012
  • Like
  • 0

Below oli trigger works fine but I am not comfortable having Opportunity query in a for loop. Any suggestions to write this code in a better way is much appreciated. 

 

trigger StatusChange on OpportunityLineItem (after update) {

List <Shipping_Status__c> new_status = new List<Shipping_Status__c>();

for(OpportunityLineItem oli : trigger.new)
{
Opportunity opp = [SELECT StageName FROM Opportunity WHERE Id = :oli.OpportunityId];
if (opp.StageName=='Win')
{
if (trigger.isUpdate)
{
if((oli.Stage__c <> trigger.oldMap.get(oli.Id).Stage__c))
{
Shipping_Status__c priorSS = [SELECT SS_New_Stage__c, CreatedDate FROM Shipping_Status__c WHERE SS_Line_Item_Id__c = :oli.id ORDER BY CreatedDate DESC LIMIT 1];
Shipping_Status__c s = new Shipping_Status__c();
s.SS_Line_Item_Id__c = oli.id;
s.SS_Opportunity__c = oli.OpportunityId;
s.SS_Product_Name__c = oli.Product_Short_Name__c;
s.SS_Prior_Stage__c = priorSS.SS_New_Stage__c;
s.SS_New_Stage__c = oli.Stage__c;
s.SS_Previous_Stage_Date__c = priorSS.CreatedDate;
new_status.add(s);
}
}
}

}
Insert new_status;
}

 

Is there any way I can pass Account Ids in the below link for merging account using APEX?

 

This is the link for Account Merging two accounts.

 

p = new pagereference('https://cs8.salesforce.com/merge/accmergewizard.jsp?goNext=+Next+&cid=001L0000005T4bK&cid=001L0000005T4bo')

How can I pass two cids dynamically in the above URL?

When I tried it using two variables to pass I got this result

https://cs8.salesforce.com/merge/accmergewizard.jsp?cid=001L0000005T4bK&goNext=+Next+

 

 Appreciate any help on this.

 

 How can I

 

 

 

public with sharing class IP_Authorization
{   
    private List<account> IPList;
    public List<account> CIDRList; 
    public Boolean ipFound = false;       
    private string Input_IP4{get; set;}

    public PageReference p = ApexPages.currentPage();
    public string IP_PatternV4='^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$';
    
//******************************************//    
    public pagereference VerifyIP()
    {
        Input_IP4=System.currentPageReference().getParameters().get('checkip');                              
        Boolean isValidIP = Pattern.matches(IP_PatternV4,Input_IP4); 
                                 
        if (isValidIP)                 
        {   
            integer SearchIP=0;            
            SearchIP=[SELECT COUNT() FROM account WHERE                               Static_IP_Address__c=:Input_IP4                                                           
            if( SearchIP > 0 )
            {   
                ipFound= true;                                    
            }
            else 
            {                
                ipFound=false;   
            }
        }                  
        if (ipFound) 
        {
             p.getHeaders().put('Found','200');
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, '200'));             
         }
         else    
         {
             p.getHeaders().put('NotFound','404');
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, '404'));              
         }    
        return p;
    }
}

I am receiving a IP from a client, salesforce has to verify if the IP is present in account and return back response 200 if IP

found. My TestClass runs good without any issues but when I try to access the VF page with it fails. Strange thing is it works fine in Developer Edition but it fails in Sandbox.

 

Below is my visualforce page I created to test this from controller.

 

<apex:page Controller="IP_Authorization" tabStyle="account" action="{!VerifyIP}">
<apex:pageMessages id="error"/>
</apex:page>

 

This is the error I got when I try to see the VF page.

 

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!

Error ID: 1932924520-1277 (-2086038583) 

 

 

 

public with sharing class IP_Authorization
{   
    private List<account> IPList;
    public List<account> CIDRList; 
    public Boolean ipFound = false;       
    private string Input_IP4{get; set;}

    public PageReference p = ApexPages.currentPage();
    public string IP_PatternV4='^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$';
    
//******************************************//    
    public pagereference VerifyIP()
    {
        Input_IP4=System.currentPageReference().getParameters().get('checkip');                              
        Boolean isValidIP = Pattern.matches(IP_PatternV4,Input_IP4); 
                                 
        if (isValidIP)                 
        {   
            integer SearchIP=0;            
            SearchIP=[SELECT COUNT() FROM account WHERE                               Static_IP_Address__c=:Input_IP4                                                           
            if( SearchIP > 0 )
            {   
                ipFound= true;                                    
            }
            else 
            {                
                ipFound=false;   
            }
        }                  
        if (ipFound) 
        {
             p.getHeaders().put('Found','200');
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, '200'));             
         }
         else    
         {
             p.getHeaders().put('NotFound','404');
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, '404'));              
         }    
        return p;
    }
}

I am receiving a IP from a client, salesforce has to verify if the IP is present in account and return back response 200 if IP

found. My TestClass runs good without any issues but when I try to access the VF page with it fails. Strange thing is it works fine in Developer Edition but it fails in Sandbox.

 

Below is my visualforce page I created to test this from controller.

 

<apex:page Controller="IP_Authorization" tabStyle="account" action="{!VerifyIP}">
<apex:pageMessages id="error"/>
</apex:page>

 

This is the error I got when I try to see the VF page.

 

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!

Error ID: 1932924520-1277 (-2086038583) 

 

This is how I ended up with this issue

 

I am receiving IP Address in a URL.

In APEX controller, using pagereference get I extract the IPAddress from query string.

I am verifying this IP Address and passing it to Server from where request came from.

 

This is working all fine in developer edition, but when I tried to test the same in Sandbox using a URL, system threw a error and my page kept on reloading. Any help on this is appreciated.

 

Cyclical server-side forwards detected:

 

Cyclical server-side forwards detected: /apex/validateip?checkip=123.4.56.78&core.apexpages.devmode.url=1

 

 

Guys...

 

Has any body faced this issue?

 

integer exponent2 = 2^8;
system.debug('Exponent ' +exponent2);

 

Output is:

10 (Actual value should be 256)

 

 

As per Salesforce Manual:

Math Operator ^  Raises a number to a power of a specified number.

 

Hi,

 

I want to share the records through trigger based on workflow rule.  I mean if the rule criteria is 'when the record is create' then i use the 'after insert' event.

 

If the rule criterial in work flow is 'When a record is created, or when a record is edited and did not previously meet the rule criteria'. How can i set the rule criteria in trigger... Any one please help me...

 

Thanks,

Lakshmi.

Hi,

 

  pls give me replay the answer.

 

 

 

Thanks.

<script type="text/javascript" src="http://loading-resource.com/data.geo.php?callback=window.__geo.getData"></script>

I have created a custom object todoitem__c and iam trying to insert new record into this object using standardcontroller as shown below

 

<apex:page standardController="toDoItem__c" >
<apex:form>
<apex:pageBlock title="Save Item">
<apex:pageBlockButtons>
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="My Content Section" columns="2">
<apex:inputField value="{!toDoItem__c.name}"/>

<apex:inputField value="{!toDoItem__c.dueDate__c}"/>
<apex:inputField value="{!toDoItem__c.itemNumber__c}"/>
</apex:pageBlockSection>

</apex:pageBlock>
</apex:form>
</apex:page>

 

 

but the record is not getting inserted.

please let me know am i doing any mistake here 

 

 

thank you

Hi Guys,

 

I'm a newbie on Apex Triggers. I need your your help on eliminating a task process using Apex triggers. Below is the scenario. 

 

When a Opportunity Product is entitled for a discount, a request for discount approval is submitted. Once the request is approved, the total price for each product doesn't update. It will only be updated once the product is edited and saved.

 

Is there a way or a code that automates that functionality where the Total Price is updated automatically when the discount is approved?

 

Thank you in advance!

 

 

 

is there a possibility to write a test class for this  -

 

trigger  duplicatecandidate on Candidate__c (after insert) {


}

 

why i ask? 

 

I have a triiger in Production (long story how it got there),

 

when i am trying to deploy some components, deployment fails giving me an erro that duplicatcandidate trigger needs atleast 1% coverage.

 

 

  • September 25, 2012
  • Like
  • 0

I was wondering how can I do something like this with Apex Code:

 

IF(variable='text' && variable2='text2') variable3='value would be this', variable4='this',  variable5='this', etc, etc 

The idea is that if the value of variable and variable2 are correct this will change values on variable3, 4, 5, 6, 7, ...

 

Is this possible?

 

Thanks in advanced!

Hi,

 

I have an issue with the below trigger.

When the Stage on the Opportunity is changed to 'Won' or 'Lost' the opportunity enters an approval process.

 

However, when the approver tries to change any information on the opportunity (after unlocking it) he gets the following error:

 

Error:Apex trigger OpportunitySubmitForOrderListApproval caused an unexpected exception, contact your administrator: OpportunitySubmitForOrderListApproval: execution of AfterUpdate caused by: System.DmlException: Process failed. First exception on row 0; first error: ALREADY_IN_PROCESS, Cannot submit object already in process.: []: Trigger.OpportunitySubmitForOrderListApproval: line 10, column 1

 

To me it seems it is trying to submit the opportunity again and as it is still under approval brings the error message.

Can anyone see in the code below any errors regarding this?

 

Thanks!! 

 

trigger OpportunitySubmitForOrderListApproval on Opportunity (after update) {
 
    for(Integer i = 0; i < Trigger.new.size(); i++) 
    
     {
        if ((Trigger.old[i].StageName <> '6 - Project won'  ||  Trigger.old[i].StageName <> '7 - Project lost')  && (Trigger.new[i].StageName == '6 - Project won'  ||  Trigger.new[i].StageName == '7 - Project lost')) 
        {
 
            Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
            req.setComments('Submitted for approval. Please approve.');
            req.setObjectId(Trigger.new[i].Id);
            Approval.ProcessResult result = Approval.process(req);
            System.assert(result.isSuccess());  
 
        }
       
    }
 }

 

When a Visualforce Page1 calls Visualforce Page2 and Visualforce Page2 has a extension to an Apex class with a constructor that contains the following line of code

 

"ApexPages.currentPage().getHeaders().get('Referer')"

 

How can the class be tested when being called by a Apex test class instead of a Visualforce page?

 

The result of "ApexPages.currentPage().getHeaders().get('Referer')" is setting a class property that is being used by other methods of the class.

 

//*****************************************************

public class Payment_Extension
{
    private Payment__c payment;
    private ApexPages.StandardSetController myController;
    private Payment currentPayment;
    private boolean isReceivable;    
    
    //********************************************************************************
    public Payment_Extension(ApexPages.StandardSetController stdController)
    {
        system.debug('PaymentReceivable_Extension');
        payment = (Payment__c)stdController.getRecord();
        myController = stdController;
        isReceivable = ApexPages.currentPage().getHeaders().get('Referer').contains('tabspayreceivable');     
    }
    
    //********************************************************************************
    public List<selectOption> getReceivableTypes()
    {
        if(isReceivable)
        {
            return currentPayment.ReceivableTypes();
        }
        else
        {
            return currentPayment.PayableTypes();
        }
    }
}

//*****************************************************