• Amritesh Sahu
  • NEWBIE
  • 310 Points
  • Member since 2014
  • Salesforce Developer

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 50
    Replies
Hi All,

I have a VF page which shows all the products and its related prices and other fields as well. But in the VF page, products are coming many times(duplication is not an issue) and i need to group all the products with similar name like we do in the Reports standard functionality. Suppose there are 10 records for the same product "Study", it should only show one study value with other records being grouped.

Below is the VF Page :
<apex:page tabStyle="Apttus_Proposal__Proposal__c"  standardController="Apttus_Proposal__Proposal__c"
                                                   extensions="DiscountReportExtension" sidebar="false">
  
    <apex:form >
     <apex:pageBlock title="Discount Sheet" id="pg1">
       <apex:pageBlockButtons location="Top">          
            <apex:actionFunction name="exportToExcel" action="{!exportToExcel}" rerender="refresh" status="myStatus" onComplete="window.close();"/>
             <input type="button" value="Export To Excel" onclick="exportToExcel();" />
       </apex:pageBlockButtons>
     </apex:pageBlock>
     
    <apex:pageBlock >
    <apex:pageBlockTable value="{!PLIlist}" var="pli">      
        <apex:column headerValue="Client Service Name" value="{!pli.APTPS_Client_Service_Name__c}"/>
        <apex:column headerValue="Product name" value="{!pli.Apttus_Config2__ProductId__c}"/>
        <apex:column headerValue="Option" value="{!pli.Apttus_Config2__OptionId__r.name}"/>        
        <apex:column headerValue="Product code" value="{!pli.Apttus_Config2__ProductId__r.ProductCode}"/>
        <apex:column headerValue="Region" value="{!pli.Apttus_Config2__ChargeType__c}"/>
        <apex:column headerValue="List Price" value="{!pli.Apttus_Config2__ListPrice__c}"/>
        <apex:column headerValue="Unit Net Price" value="{!pli.APTS_Unit_Net_Price__c}"/>
        <apex:column headerValue="Standard Price" value="{!pli.Adj_Amount_From_Price_List_Item__c}"/>
        <apex:column headerValue="Standard Price - List Price" value="{!pli.Diff_b_w_LP_Adj_Amt__c}"/>
        <apex:column headerValue="Standard Price - Unit Net Price" value="{!pli.Diff_b_w_UNP_Adj_Amt__c}"/>
        <apex:column headerValue="(Standard Price - List Price)%" value="{!pli.Diff_b_w_LP_Adj_Amt_in__c}"/>
        <apex:column headerValue="(Standard Price - Unit Net Price)%" value="{!pli.Diff_b_w_UNP_Adj_Amt_in__c}"/>      
     </apex:pageBlockTable> 
     </apex:pageBlock>
    
    </apex:form>    
</apex:page>

Below is the Apex class :
public class DiscountReportExtension {
    public Apttus_Proposal__Proposal__c prop {get;set;}
    public Static Transient List<Apttus_Config2__LineItem__c> PLIlist{get; set;}
    public Id propId;
    
    
    Public DiscountReportExtension(ApexPages.StandardController stdController){               
        this.prop = (Apttus_Proposal__Proposal__c)stdController.getRecord();
        propId = prop.Id;    
               
        PLIlist = new List<Apttus_Config2__LineItem__c>([select id,name,APTPS_Client_Service_Name__c,Apttus_Config2__OptionId__r.name,Apttus_Config2__AttributeValueId__r.APTS_Specimen_Type__c,             Apttus_Config2__ProductId__r.ProductCode,Apttus_Config2__ProductId__r.APTS_Lab_Name__c,Apttus_Config2__ProductId__r.APTS_Methodology__c,Apttus_Config2__ProductId__r.APTS_Analyser_Type__c,
                  Apttus_Config2__AttributeValueId__r.APTS_Transport_Temperature__c,Apttus_Config2__ProductId__r.APTS_Stability_Temperature__c, Apttus_Config2__ProductId__r.APTS_Stability__c,
                  Apttus_Config2__AttributeValueId__r.APTS_Collection_Container__c,Apttus_Config2__ProductId__r.APTS_Optimum_Sample_Volume__c, Apttus_Config2__ProductId__r.APTS_Minimum_Sample_Volume__c,                Apttus_Config2__ProductId__r.APTS_Lab_Code__c,Apttus_Config2__ProductId__r.APTS_Lab_Turnaround_Time__c,APTS_Unit_Net_Price__c,Apttus_Config2__ListPrice__c,Adj_Amount_From_Price_List_Item__c,                Apttus_Config2__ChargeType__c,Diff_b_w_LP_Adj_Amt__c,Diff_b_w_LP_Adj_Amt_in__c,Diff_b_w_UNP_Adj_Amt_in__c,Diff_b_w_UNP_Adj_Amt__c,Apttus_Config2__ProductId__c from 
Apttus_Config2__LineItem__c where Apttus_Config2__ConfigurationId__r.Apttus_Config2__Status__c = 'Finalized' AND Apttus_Config2__Quantity__c != 0 AND Apttus_Config2__Quantity__c != null AND  
Apttus_Config2__LineItem__c.Apttus_Config2__ConfigurationId__r.Apttus_QPConfig__Proposald__c =: propId ORDER BY Apttus_Config2__ProductId__c]);     
        
      }
    
    public PageReference exportToExcel() 
    {
        PageReference pg = new PageReference('/apex/ExportDiscountReport?propId='+propId);
        pg.setRedirect(true);
        return pg;
    }
 }

I tried it using Aggregate query but couldn't succeed. Any help would be greately appreciated. Thanks in advance. 
Hi All,

I'm trying to create a trigger (or use workflow rules) to update fields on the child record of a child record and I'm not sure how to do it (if it's even possible). 

The parent object is called Project__c.  Project__c is the parent to multiple Phase__c records which are parent to multiple Task__c records. When the Project_Status__c field on Project__c is set to cancelled, all associated Task__c records (under the associated Phase__c records) should be have the checkbox field IsCompleted__c set to TRUE and N_A__c checkbox set to TRUE.  Does anyone know how I can do this?
Hi folks,
        Can anyone tell me how to convert the date format to string format in JavaScript Remoting?
Below is my code

                                      
@RemoteAction
    global static theHRMS__Employee__c getEmployee() {
Contact c=[select birthdate__c from contact where id=0039000001CoN3m];
return c;
}

My VFP:
Visualforce.remoting.Manager.invokeAction(
                            '{!$RemoteAction.NewUIEmployeeContr.getEmployee}',
                            
                            function(result, event){
                                if (event.status) {
                                     Var bdate=result.birthdate__c ;

                                      alert(bdate);
                                     }

The above code gives alert message like 731808000000
But my actual birthdate is 22/11/1992


I dono how to convert  the date to string ?




Thanks in advance
Karthick
Hi, 

I have requirement here:

When XYZ contact is created, check if a XYZ Company with exact Company Name field on Account exists.
If exists, link contact to the account. If Company does not exist, then create a new XYZ Account and set owner.

trigger TriggerContactInsert on Contact (before insert) {
List<String> cntCompName = new List<String>();

   for(Contact xcnt: trigger.new)
    {
      cntCompName.add(xcnt.Company_Name__c);
    }

   list<Account> acctLst = [select Id, Name,(select Company_Name__c from Contacts) from Account where Name IN :cntCompName];
   system.debug('Account' + acctLst);
  
   Map<id,List<Contact>> mapofCmpNames = new Map<id,List<Contact>>();

    for(Account l : acctlst)
    {
       
        for(List<Contact> e : l.Contacts)
        {
            mapofCmpNames.put(l.id, e);
        }
    }
  
   for(Contact xcnt: trigger.new)
   {
        List<Contact> existingCmp = mapofCmpNames.get(xcnt.Company_Name__c);
        for(Contact xcntc: existingCmp) {
        if(xcnt.Company_Name__c  == xcntc.Company_Name__c)
        {
            //Link contact to Account
        }
       else
      {
         //create new account
     }
   }
}
}


Is there any other approach I can follow?
Below is my script to disable/enable commandButton:

<script>
function func(){
if (document.getElementById('{!$Component.form1.orderedCheckBox}').checked
     || document.getElementById('{!$Component.form1.receivedCheckBox}').checked) {
         document.getElementById('{!$Component.form1.cButton}').disabled=false
         document.getElementById('{!$Component.form1.cButton}').setAttribute('class','btn');
} else {
         document.getElementById('{!$Component.form1.cButton}').disabled=true
         document.getElementById('{!$Component.form1.cButton}').setAttribute('class','btnDisabled');
}
}
</script>

So, indirectly is is disabling HTML commandButton (to which apex:commandButton is converted but Salesforce Controller will not know that).
Suppose if we do:

<apex:commandButton id="cButton" value="Click Here" action="{!method1}"
            disabled="true"/>

In this case javaScript will make it visible and clickable on HTML page if we check any checkbox but it will never call method method1() of Controller because according to Salesforce it is disabled and so redirect to same page without showing anything (any error or debug or anything).

So, it doesn't seem to be correct method and I don't want to use actionSupport for this as the effect will be delayed. Like when we uncheck a checkbox. It will take little time to make button disable. Also, I don't want to make communication through Salesforce happen only for this thing.

JQuery will also be doing same thing. It will not be changing real <apex:commandButton> but commandButton in HTML which Salesforce Server will not consider.

Also, I know from javaScript Console that we have to change class to 'btnDisabled' or 'btn'.
If in future Salesforce change the class names it uses my code will fail. So, assigning class to it also doesn't seem to be correct but without it the appearance will not change. Disabled commandButton will look like Enabled.

So, Is there any better/correct way to do this?
I have a function JS to check if a checkbox is checked, but does not work. Why?

<apex:page standardController="CronTrigger" >

<style type="text/css">
        .classeHoraire { width: 60px; }
        .classeBig { width: 600px; }
        .imageCenter {display: block; margin-left: auto; margin-right: auto;}
</style>
    
<script type="text/javascript">

function verify(){
var checkNomJob = '{!verifiyNomJob}';

if (document.getElementById("{!$Component.theform.block01.pageSess01.outputPane01.ckLun}").checked){
    alert("Messageee");
}
}
</script>

  <apex:form id="theform" > 
  <apex:PageBlock id="block01">

    Job Name.:&nbsp;<apex:inputText id="nomJobIP" value="{!nomJob}" />  
    <br /><br />
        
 <br/><br/>
 <apex:pageBlockSection columns="2" id="pageSess01">
    <apex:outputPanel id="outputPane01">
    
    <apex:inputCheckbox id="ckLun" value="{!checkLundi}" disabled="{!disableSemaineCheckModification}" />Lundi<br />
    <apex:inputCheckbox id="ckMar" value="{!checkMardi}" disabled="{!disableSemaineCheckModification}" />Mardi<br />
    </apex:outputPanel>
</apex:pageBlockSection>

.....

</apex:page>

I have a datatable displaying a custom object in my visualforce page, currently I display a output link in my last column to link to the detail page for the record.
How can I make the whole row clickable to the detail page?
The Transaction_Amount__c is not updating in the Investor_Banking_Info_Entries__c object,iam retrieving the value in Amount variable,Can anyone please tell how to assign this varible to Transaction_Amount__c field

public class importDataFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public string Amount;



public List<Investor_Banking_Info_Entries__c> acclist{get;set;}
  public importDataFromCSVController(){
    csvFileLines = new String[]{};
    acclist = New List<Investor_Banking_Info_Entries__c>();
       
  }
 
  public void importCSVFile(){
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n');
            
           for(Integer i=1;i<csvFileLines.size();i++){
           
               Investor_Banking_Info_Entries__c accObj = new Investor_Banking_Info_Entries__c() ;
                 
               
               string[] csvRecordData = csvFileLines[i].split(',');
               accObj.Investor_Name__c = csvRecordData[0] ;
               accObj.Account_Number__c  = csvRecordData[1];  
               Amount  = csvRecordData[2];
              System.debug('The value isSSSSSSSSSSSSSSSSSSSSSSSSSS: ' +Amount );
                           
              Amount = string.valueof(accObj.Transaction_Amount__c);
               
               System.debug('The value is: ' +Amount );
                           
               acclist.add(accObj);   
           }
        insert acclist;
        }
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        }  
  }
}
Hi All,

I have a VF page which shows all the products and its related prices and other fields as well. But in the VF page, products are coming many times(duplication is not an issue) and i need to group all the products with similar name like we do in the Reports standard functionality. Suppose there are 10 records for the same product "Study", it should only show one study value with other records being grouped.

Below is the VF Page :
<apex:page tabStyle="Apttus_Proposal__Proposal__c"  standardController="Apttus_Proposal__Proposal__c"
                                                   extensions="DiscountReportExtension" sidebar="false">
  
    <apex:form >
     <apex:pageBlock title="Discount Sheet" id="pg1">
       <apex:pageBlockButtons location="Top">          
            <apex:actionFunction name="exportToExcel" action="{!exportToExcel}" rerender="refresh" status="myStatus" onComplete="window.close();"/>
             <input type="button" value="Export To Excel" onclick="exportToExcel();" />
       </apex:pageBlockButtons>
     </apex:pageBlock>
     
    <apex:pageBlock >
    <apex:pageBlockTable value="{!PLIlist}" var="pli">      
        <apex:column headerValue="Client Service Name" value="{!pli.APTPS_Client_Service_Name__c}"/>
        <apex:column headerValue="Product name" value="{!pli.Apttus_Config2__ProductId__c}"/>
        <apex:column headerValue="Option" value="{!pli.Apttus_Config2__OptionId__r.name}"/>        
        <apex:column headerValue="Product code" value="{!pli.Apttus_Config2__ProductId__r.ProductCode}"/>
        <apex:column headerValue="Region" value="{!pli.Apttus_Config2__ChargeType__c}"/>
        <apex:column headerValue="List Price" value="{!pli.Apttus_Config2__ListPrice__c}"/>
        <apex:column headerValue="Unit Net Price" value="{!pli.APTS_Unit_Net_Price__c}"/>
        <apex:column headerValue="Standard Price" value="{!pli.Adj_Amount_From_Price_List_Item__c}"/>
        <apex:column headerValue="Standard Price - List Price" value="{!pli.Diff_b_w_LP_Adj_Amt__c}"/>
        <apex:column headerValue="Standard Price - Unit Net Price" value="{!pli.Diff_b_w_UNP_Adj_Amt__c}"/>
        <apex:column headerValue="(Standard Price - List Price)%" value="{!pli.Diff_b_w_LP_Adj_Amt_in__c}"/>
        <apex:column headerValue="(Standard Price - Unit Net Price)%" value="{!pli.Diff_b_w_UNP_Adj_Amt_in__c}"/>      
     </apex:pageBlockTable> 
     </apex:pageBlock>
    
    </apex:form>    
</apex:page>

Below is the Apex class :
public class DiscountReportExtension {
    public Apttus_Proposal__Proposal__c prop {get;set;}
    public Static Transient List<Apttus_Config2__LineItem__c> PLIlist{get; set;}
    public Id propId;
    
    
    Public DiscountReportExtension(ApexPages.StandardController stdController){               
        this.prop = (Apttus_Proposal__Proposal__c)stdController.getRecord();
        propId = prop.Id;    
               
        PLIlist = new List<Apttus_Config2__LineItem__c>([select id,name,APTPS_Client_Service_Name__c,Apttus_Config2__OptionId__r.name,Apttus_Config2__AttributeValueId__r.APTS_Specimen_Type__c,             Apttus_Config2__ProductId__r.ProductCode,Apttus_Config2__ProductId__r.APTS_Lab_Name__c,Apttus_Config2__ProductId__r.APTS_Methodology__c,Apttus_Config2__ProductId__r.APTS_Analyser_Type__c,
                  Apttus_Config2__AttributeValueId__r.APTS_Transport_Temperature__c,Apttus_Config2__ProductId__r.APTS_Stability_Temperature__c, Apttus_Config2__ProductId__r.APTS_Stability__c,
                  Apttus_Config2__AttributeValueId__r.APTS_Collection_Container__c,Apttus_Config2__ProductId__r.APTS_Optimum_Sample_Volume__c, Apttus_Config2__ProductId__r.APTS_Minimum_Sample_Volume__c,                Apttus_Config2__ProductId__r.APTS_Lab_Code__c,Apttus_Config2__ProductId__r.APTS_Lab_Turnaround_Time__c,APTS_Unit_Net_Price__c,Apttus_Config2__ListPrice__c,Adj_Amount_From_Price_List_Item__c,                Apttus_Config2__ChargeType__c,Diff_b_w_LP_Adj_Amt__c,Diff_b_w_LP_Adj_Amt_in__c,Diff_b_w_UNP_Adj_Amt_in__c,Diff_b_w_UNP_Adj_Amt__c,Apttus_Config2__ProductId__c from 
Apttus_Config2__LineItem__c where Apttus_Config2__ConfigurationId__r.Apttus_Config2__Status__c = 'Finalized' AND Apttus_Config2__Quantity__c != 0 AND Apttus_Config2__Quantity__c != null AND  
Apttus_Config2__LineItem__c.Apttus_Config2__ConfigurationId__r.Apttus_QPConfig__Proposald__c =: propId ORDER BY Apttus_Config2__ProductId__c]);     
        
      }
    
    public PageReference exportToExcel() 
    {
        PageReference pg = new PageReference('/apex/ExportDiscountReport?propId='+propId);
        pg.setRedirect(true);
        return pg;
    }
 }

I tried it using Aggregate query but couldn't succeed. Any help would be greately appreciated. Thanks in advance. 
Hi how to implement a custom save logic using standard controller on a custom sobject
Hi,
How to get the custom setting values in the apex code.
I have a wrapper class with an Integer list.  In the VF page when I try and save, I get Error: Unknown Property 'xxx 'when I try and use an inputText. However, it saves and displays correctly if I use an outputText.  Here is a partial list of the code VF page and class:
<apex:repeat value="{!listWProduct}" var="prd">        
<tr>
  <th style="text-align:center;"><apex:inputcheckbox value="{!prd.isSelected}"/></th>
  <th style="text-align:left;"><apex:outputField value="{!prd.p2.Name}"/></th>
     <apex:repeat value="{!prd.listTerm}" var="xxx">                  
       <td style="text-align:center;">
        <apex:inputText value="{!xxx}"/> get Unknown Property: 'xxx' when trying to save VF page
        <apex:outputText value="{!xxx}"/> this works and VF page saves
       </td>
    </apex:repeat>
</tr>
</apex:repeat>

    public class wProduct implements Comparable
    {
        public Product2            p2             {get;set;}
        public Boolean             isSelected     {get;set;}
        public Integer[]             listTerm       {get;set;}
        
        public wProduct (Product2 p2)
        {
            this.p2      = p2;
            isSelected   = false;
            listTerm     = new Integer[]{0,0,0,0,0,0,0,0,0,0};
        } 
        
        public Integer compareTo(Object other)
        {    
            String otherName = other != null ? ((wProduct)other).p2.Name : ''; 
            return p2.Name.compareTo(otherName); 
        }
    } 

in class:
public  wProduct[]                  listWProduct                                {get;set;} 
listWProduct                        = new wProduct[]{};
for (Product2 p2 : [Select id,Name From Product2]) {
            listWProduct.add(new wProduct(p2));   
        }

 
  • January 13, 2015
  • Like
  • 0
I need to include an external library and pass the answer from the library to the controller. The example from the documentation works fine 'as is'. Here's the example (from https://developers.paymill.com/en/introduction/brief-instructions/):
<script type="text/javascript">
var PAYMILL_PUBLIC_KEY = '62477926916d4da496cf4f1a77c4175d';
</script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://bridge.paymill.com/"></script>
<script type="text/javascript">
$(document).ready(function () {

function PaymillResponseHandler(error, result) {
if (error) {
// Displays the error above the form
$(".payment-errors").text(error.apierror);
} else {
$(".payment-errors").text("");
var form = $("#payment-form");
// Token
var token = result.token;

// Insert token into form in order to submit to server
form.append("<input type='hidden' name='paymillToken' value='" + token + "'/>");
form.get(0).submit();
}
$(".submit-button").removeAttr("disabled");
}

$("#payment-form").submit(function (event) {
// Deactivate submit button to avoid further clicks
$('.submit-button').attr("disabled", "disabled");

if (!paymill.validateCardNumber($('.card-number').val())) {
$(".payment-errors").text("Invalid card number");
$(".submit-button").removeAttr("disabled");
return false;
}

if (!paymill.validateExpiry(
  $('.card-expiry-month').val(),
  $('.card-expiry-year').val())
) {
$(".payment-errors").text("Invalid expiration date");
$(".submit-button").removeAttr("disabled");
return false;
}

paymill.createToken({
number:         $('.card-number').val(),
exp_month:      $('.card-expiry-month').val(),
exp_year:       $('.card-expiry-year').val(),
cvc:            $('.card-cvc').val(),
cardholder:     $('.card-holdername').val(),
amount_int:     $('.card-amount-int').val(),   // Integer z.B. "4900" für 49,00 EUR
currency:       $('.card-currency').val()      // ISO 4217 z.B. "EUR"
}, PaymillResponseHandler);

return false;
});
});
</script>
<div class="payment-errors"></div>
<form id="payment-form" action="request.php" method="POST">
<input class="card-amount-int" type="hidden" value="4900" />
<input class="card-currency" type="hidden" value="EUR" />

<div class="form-row"><label>Card number</label>
<input class="card-number" type="text" value="4111111111111111" size="20" /></div>

<div class="form-row"><label>CVC (Prüfnummer)</label>
<input class="card-cvc" type="text" value="111" size="4" /></div>

<div class="form-row"><label>Name</label>
<input class="card-holdername" type="text" value="Joe Doe" size="20" /></div>

<div class="form-row"><label>Expiry Date (MM/YYYY)</label>
<input class="card-expiry-month" type="text" value="02" size="2" />
<span> / </span>
<input class="card-expiry-year" type="text" value="2015" size="4" /></div>

<div class="form-row"><label>Currency</label>
<input class="card-currency" type="text" value="EUR" size="20" /></div>

<button class="submit-button" type="submit">Submit</button>

</form>

Since I'm not that into JS, maybe someone could help me adopt this to Visualforce. I have more <apex:inputFields> on the VF-Page and a complete <apex:form> with own <apex:commandbutton> to submit the inputfields to the controller. I'd like to have only one form, if possible. If not, I'd like to send the "token" var from the JS to a controller variable.

Any help is appreciated!

I'm trying to write a trigger to make sure certain fields are not empty based on the status that is chosen.  I have several different types of fields I'm trying to validate.  My code is below but it doesn't seem to be validating anything

Resolution_Detail__c = RTF
Workaround_ICA__c = RTF
Defect_Type_Multi__c = multipicklist
Declined_Reason__c= picklist
NPI_Numbertext__c = plain text
NPI_Tracking_Link__c = URL
CPI_Numbertext__c = plain text
CPI_Tracking_Link__c = URL
Change_Numbertext__c = plain text
CPI_Tracking_Link__c = URL





 
trigger CWStatusValidation on Case (before update, before insert)
{

              
        for (Case objCase : Trigger.new)
        {
           //If Status is any of the following and Resolution Detail is empty, prompt to fill in.
           if((objCase.Status == 'Closed - Cancelled' || objCase.Status == 'Closed - Unable to Reproduce' || objCase.Status == 'Closed - Duplicate'
           || objCase.Status == 'Recurring Incident') && objCase.Resolution_Detail__c == '')            
           {
                trigger.new[0].addError('Please fill in the Resolution Detail for this case.');
           }
              //If Status is any of the following and ICA is empty, prompt to fill in.
              if((objCase.Status == 'Pending - RCA' || objCase.Status == 'Pending - Customer Validation' 
              || objCase.Status == 'Pending - Dealer Validation' || objCase.Status == 'Pending - Evaluation') && objCase.Workaround_ICA__c == '')             
              {
                trigger.new[0].addError('Please fill in the Workaround / ICA for this case.');
              }
                    //If Status = Pending - CPI, fill in Resolution Details, CPI Number and CPI Tracking Link
                    if(objCase.Status == 'Pending - CPI' && objCase.CPI_Numbertext__c == ' ' && objCase.CPI_Tracking_Link__c == ' ' && objCase.Resolution_Detail__c == '' )            
                    {
                        trigger.new[0].addError('Please fill in the Resolution Details, CPI Number and CPI Tracking Link for this case.');
                    }
                         //If the Status = Closed - Declined, fill in Resolution Detail, Defect Type and Declined Reason.
                         if(objCase.Status == 'Closed - Declined' && objCase.Resolution_Detail__c == '' && objCase.Defect_Type_Multi__c == '' && objCase.Declined_Reason__c == '')
                         {
                           trigger.new[0].addError('Please fill in the Resolution Details, Defect Type and Declined Reason for this case.');
                         }
                            //If the Status = Pending - NPI, fill in Resolution Detail, NPI Number and NPI Tracking Link.
                            if(objCase.Status == 'Pending - NPI' && objCase.Resolution_Detail__c == '' && objCase.NPI_Numbertext__c == null && objCase.NPI_Tracking_Link__c == null)
                            {
                               trigger.new[0].addError('Please fill in the Resolution Details, NPI Number and NPI Tracking Link for this case.');
                            }
                                //If the Status = Pending - Change, fill in Resolution Detail, Change Number and Change Tracking Link.
                                if(objCase.Status == 'Pending - Change' && objCase.Resolution_Detail__c == '' && objCase.Change_Number__c == '' && objCase.Change_Tracking_Link__c == '')
                                {
                                   trigger.new[0].addError('Please fill in the Resolution Details, Change Number and Change Tracking Link for this case.');
                                }
                                    //If the Status is any of the following, fill in Resolution Detail and Defect Type.
                                    if((objCase.Status == 'Closed - Resolved' || objCase.Status == 'Closed - No Response') && objCase.Resolution_Detail__c == '' && objCase.Defect_Type_Multi__c == '' )
                                    {
                                       trigger.new[0].addError('Please fill in the Resolution Details and Defect Type for this case.');
                                    }
           
         }       
}
  • November 24, 2014
  • Like
  • 1
I am new to Apex and I am having trouble with changing the record type of a record on a visualforce page.  Here is what is happening.


If I try to use this as an Apex Class,
 
public class LoadRecordType {

    Account a;
    
    public LoadRecordType(ApexPages.StandardController controller) {
        a=(Account)controller.getRecord();
    }
    
    public PageReference setRecordType(){
        a.RecordTypeId=[Select Id,SobjectType,Name From RecordType where Name ='VCHospital' and SobjectType ='Account'  limit 1].id;
        update a;
        return null;
    }
}

And reference this extension on the visualforce page like this.
 
<apex:page standardController="Account" extensions="LoadRecordType" action="{!setRecordType}">
    <apex:detail subject="{!account}"/>
</apex:page>

I get this error.

Visualforce Error
System.QueryException: List has no rows for assignment to SObject
Error is in expression '{!setRecordType}' in component <apex:page> in page accountdetailbutton: Class.LoadRecordType.setRecordType: line 10, column 1
Class.LoadRecordType.setRecordType: line 10, column 1


Im kind of a visualforce Newb.  Can someone help me figure out why this is happening?
Hi All,

I'm trying to create a trigger (or use workflow rules) to update fields on the child record of a child record and I'm not sure how to do it (if it's even possible). 

The parent object is called Project__c.  Project__c is the parent to multiple Phase__c records which are parent to multiple Task__c records. When the Project_Status__c field on Project__c is set to cancelled, all associated Task__c records (under the associated Phase__c records) should be have the checkbox field IsCompleted__c set to TRUE and N_A__c checkbox set to TRUE.  Does anyone know how I can do this?
Hi,
I want workflow to send email if the diffrence between created date and closed date of the opportunity is less than 15 days.............
Hi All,

I'm trying to achieve the preview of my related content attached to my record (always PDF document) on my custom object as a section with Visual Page. So far I was able to create a simple visual page and embedded to my record page layout but I don't know of how to make that page will preview my PDF document taken from related content section.
I appriciate any help.
Thank you
 
Hi folks,
        Can anyone tell me how to convert the date format to string format in JavaScript Remoting?
Below is my code

                                      
@RemoteAction
    global static theHRMS__Employee__c getEmployee() {
Contact c=[select birthdate__c from contact where id=0039000001CoN3m];
return c;
}

My VFP:
Visualforce.remoting.Manager.invokeAction(
                            '{!$RemoteAction.NewUIEmployeeContr.getEmployee}',
                            
                            function(result, event){
                                if (event.status) {
                                     Var bdate=result.birthdate__c ;

                                      alert(bdate);
                                     }

The above code gives alert message like 731808000000
But my actual birthdate is 22/11/1992


I dono how to convert  the date to string ?




Thanks in advance
Karthick

 i am trying to add Phone and Status field from Campaign Members Object to my VF page.How can i modify my for loop if i want to print Phone and Status field from campaign Members.

Below is my for loop

 for(Campaign c :[Select ID,(SELECT Id,CampaignId,Status  FROM CampaignMembers where CampaignId =:camp.Id) FROM campaign WHERE id=:camp.Id ]){
                   
              
              for(Lead ld : CampaignMembers) {
                   
              
                         if ((ld.ActivityHistories.size() == 0) || ld.ActivityHistories.size() == null) {
                      
                        lMemberWrappers.add(new MemberWrapper(ld.Phone,ld.CampaignMembers.get(0).Status));
                       
                        }}}

and SOQL Query is

CampaignMembers= [Select Id, Phone,(Select id, Status From CampaignMembers where CampaignId =:camp.Id  ),
        (Select Subject, Id,lastModifiedDate From ActivityHistories    order by LastModifiedDate DESC  LIMIT 1  )
        From Lead  where Id IN(select LeadId from campaignMember where campaignId =:camp.Id ) ];
I have created a dynamic soql in controller but while using it with IN operator its not showing the query properly....
<apex:page controller="dynamicsoql">
    <apex:form>
        <apex:pageBlock >
            <apex:pageBlockSection id="pbs">
                <apex:outputText>{!idinlist}</apex:outputText>
                <apex:inputTextarea value="{!query}" />
            </apex:pageBlockSection>
            <apex:commandButton action="{!showid}" value="showid" reRender="pbs"/>
            <apex:commandButton action="{!showquery}" value="showquery" reRender="pbs"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>
.........................................................................
public class dynamicsoql {
    public list<j__c> recordid { get; set; }
    public string singleid{get;set;}
    public list<string> idinlist{get;set;}
    public string query {get;set;}
    public dynamicsoql()
    {
     recordid=[select id from j__c];
     idinlist=new list<string>();
    }
    public void showid()
    {
        for(j__c j: recordid)
        {
            singleid='\''+string.valueOf(j.id)+'\'';
            idinlist.add(singleid);
        }
    }
    public void showquery()
    {
        query ='select name from j__c where id in '+  idinlist ;
    }
}

In my controller their is a dynamic soql query----

(((((((((((query ='select name from j__c where id in '+  idinlist ;))))))))))))))))

in this query ""idinlist"" is a list of id's. If in the list their are only 10 id then its fine and the query is printed in the vf page in this form
select name from j__c where id in ('a019000000FRJDkAAP', 'a019000000FRJDzAAP', 'a019000000FRJEdAAP', 'a019000000FRJEeAAP', 'a019000000FRJFCAA5', 'a019000000FRJFDAA5', 'a019000000FRJFEAA5', 'a019000000FRJFFAA5', 'a019000000FRJFlAAP', 'a019000000FRJGSAA5')

but if  ""idinlist"" has more then 10 id's then its query is printed in this form

select name from j__c where id in ('a019000000FRJDkAAP', 'a019000000FRJDzAAP', 'a019000000FRJEdAAP', 'a019000000FRJEeAAP', 'a019000000FRJFCAA5', 'a019000000FRJFDAA5', 'a019000000FRJFEAA5', 'a019000000FRJFFAA5', 'a019000000FRJFlAAP', 'a019000000FRJGSAA5',...)

means after 10th id it's just showing '''...''' and no id. i had printed the query in vf page system debug every where it's the same.
and because of that my query is not working. Please help.


how can i pass a javascript variable to apex variable?
i need to use the apex variable on the if condition for list item class style.

PAGE:
<ul>
    <li class="{!IF(a==true && b==false, 'tabStyle1', 'tabStyle2')}">
        P&amp;L Entry
    </li>
    <li class="{!IF(a==false && b==true, 'tabStyle1', 'tabStyle2')}">
        P&amp;L Search
    </li>
</ul>

<div id="DivID1">
    text1
</div>
<div id="DivID2">
    text2
</div>
<style>
    .tabStyle1 {
        backgroound-color: red;
    }
    .tabStyle2 {
        backgroound-color: blue;
    }
</style>


Controller:
public String a {get;set;}
public String b {get;set;}

public void showA() {
     //a = __________;   <----pass this javascript: $("#DivID1").is(":visible");
     //b = __________;   <----pass this javascript: $("#DivID2").is(":visible");
}



  • July 09, 2014
  • Like
  • 0