• Prad Nethas
  • NEWBIE
  • 25 Points
  • Member since 2013
  • Salesforce Consultant

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 5
    Questions
  • 22
    Replies
Hi All,

I have a Visual force email template on a workflow action. That will fire upon creation of Account and when it meets a check box to true and not a specific profile user. To test it I also have added the task, which creates parallalely. 
Problem I am facing is when I have added the component to the Vf email template then My Vf Template is giving me an error 
Below is the error 

Error occurred trying to load the template for preview: List has no rows for assignment to SObject. Please try editing your markup to correct the problem.

What could be the possible issue can you please help me out on this.

Below is my class for the vf component which gets account id.

public class CTBnewmyresourceemail {
    List<asset> assetlist = new List<asset>();
    Account accdetails = new Account();
    public id recId;
    public Account thisAccountId { get; set; }
    public CTBnewmyresourceemail()
    {
    recId = ApexPages.currentPage().getParameters().get('Id');
   
    accdetails = [select id from account where id=:recId limit 1];
    assetlist = [select id,accountid,description from asset where accountid =:accdetails.id];
    //return assetlist;
    }
    public List<asset> getAccount_assets() {
        return assetlist;
    }    
}

Did I made any mistake in it please suggest me.
Also In the visual force page I am trying to display the asset field value of that particular account.

THanks in advance
Prad
Hi All,

I am not able to get the results when I add the picklist values to controller.
Below is the code - Please sugget me the changes to get the desired results.

<apex:page controller="searchres">
<apex:form >
<apex:pageBlock >
  <apex:sectionHeader title="Search Results"/>
              <apex:pageBlockSection >
           
              <apex:panelGrid columns="2">
                  <apex:outputText value="Country"/>
                  <apex:inputText value="{!country}"/>
                 
                  Qualification<apex:inputField label="Qualification" value="{!ban.Qualification__c}"/>
                  </apex:panelGrid><br/>
                 
                              <!--<apex:selectList title="Qualification" label="Qualification">
                             <apex:selectOptions value="{!TypeOptions}"/>
                            </apex:selectList>-->
                           
                 <apex:commandButton value="Search" action="{!login}"/>
              </apex:pageBlockSection>
              <apex:pageBlockSection >
              <apex:pageBlockTable value="{!bank}" var="bnk">
              <apex:column headerValue="Country" value="{!bnk.Country__c}"/>
              <apex:column headerValue="Qualification" value="{!bnk.Qualification__c}"/>
              </apex:pageBlockTable>
 
              </apex:pageBlockSection>
              </apex:pageBlock>
      </apex:form>
</apex:page>
 ///////////////Controller
public class searchres {
public string country{get;set;}
public string name{get;set;}
public string Qualification{get;set;}
public string quali{get;set;}
 
public list<SOV_Database__c> bank{get;set;}
Public SOV_Database__c ban{get;set;}
//this.stdAcctController = (SOV_Database__c)stdcontroller.getRecord();
public id sh;
    public void login()
    {
       
        bank = [select id,country__c,qualification__c from SOV_Database__c where country__c=:country];
    }
    public List<SelectOption> TypeOptions
   {
        get
        {
            List<SelectOption> options = new List<SelectOption>();
            Schema.DescribeFieldResult fieldResult = SOV_Database__c.country__c.getDescribe();
            List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
   
            for( Schema.PicklistEntry f : ple)
                options.add(new SelectOption(f.getLabel(), f.getValue()));
            return options;
        }
    }
}
 
Hi All,

I am not able to get the results when I add the picklist values to controller.
Below is the code - Please sugget me the changes to get the desired results.

<apex:page controller="searchres">
<apex:form >
<apex:pageBlock >
  <apex:sectionHeader title="Search Results"/>
              <apex:pageBlockSection >
           
              <apex:panelGrid columns="2">
                  <apex:outputText value="Country"/>
                  <apex:inputText value="{!country}"/>
                 
                  Qualification<apex:inputField label="Qualification" value="{!ban.Qualification__c}"/>
                  </apex:panelGrid><br/>
                 
                              <!--<apex:selectList title="Qualification" label="Qualification">
                             <apex:selectOptions value="{!TypeOptions}"/>
                            </apex:selectList>-->
                           
                 <apex:commandButton value="Search" action="{!login}"/>
              </apex:pageBlockSection>
              <apex:pageBlockSection >
              <apex:pageBlockTable value="{!bank}" var="bnk">
              <apex:column headerValue="Country" value="{!bnk.Country__c}"/>
              <apex:column headerValue="Qualification" value="{!bnk.Qualification__c}"/>
              </apex:pageBlockTable>
 
              </apex:pageBlockSection>
              </apex:pageBlock>
      </apex:form>
</apex:page>
 ///////////////Controller
public class searchres {
public string country{get;set;}
public string name{get;set;}
public string Qualification{get;set;}
public string quali{get;set;}
 
public list<SOV_Database__c> bank{get;set;}
Public SOV_Database__c ban{get;set;}
//this.stdAcctController = (SOV_Database__c)stdcontroller.getRecord();
public id sh;
    public void login()
    {
       
        bank = [select id,country__c,qualification__c from SOV_Database__c where country__c=:country];
    }
    public List<SelectOption> TypeOptions
   {
        get
        {
            List<SelectOption> options = new List<SelectOption>();
            Schema.DescribeFieldResult fieldResult = SOV_Database__c.country__c.getDescribe();
            List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
   
            for( Schema.PicklistEntry f : ple)
                options.add(new SelectOption(f.getLabel(), f.getValue()));
            return options;
        }
    }
}

 
Hi Techies,

Hope evry one doing good. I am new to Salesforce Integraiton. Can some body help me/guide me how to start with. 
What are the best practises to learn salesforce integration. Requesting you all to give me your valuable suggestions to learn salesforce integration easily, also share your examples on salesforce integration.

Thanks in advance fellows.

Great day ahead.
Regards
Prad
Hello there,

Thanks in advance.
I need little help on test classes.

I would like to get test coverage for Try & catch blocks. I am unable to cover the catch block of class. 
Can some body help me on this. As i need 90% test coverage for my class. Because of catch blocks I am not albe to complate it.

Thanks in advance.

Regards
Pradeep
Email-pulipatipradeep07@gmail.com

 
Hi All,

I have a Visual force email template on a workflow action. That will fire upon creation of Account and when it meets a check box to true and not a specific profile user. To test it I also have added the task, which creates parallalely. 
Problem I am facing is when I have added the component to the Vf email template then My Vf Template is giving me an error 
Below is the error 

Error occurred trying to load the template for preview: List has no rows for assignment to SObject. Please try editing your markup to correct the problem.

What could be the possible issue can you please help me out on this.

Below is my class for the vf component which gets account id.

public class CTBnewmyresourceemail {
    List<asset> assetlist = new List<asset>();
    Account accdetails = new Account();
    public id recId;
    public Account thisAccountId { get; set; }
    public CTBnewmyresourceemail()
    {
    recId = ApexPages.currentPage().getParameters().get('Id');
   
    accdetails = [select id from account where id=:recId limit 1];
    assetlist = [select id,accountid,description from asset where accountid =:accdetails.id];
    //return assetlist;
    }
    public List<asset> getAccount_assets() {
        return assetlist;
    }    
}

Did I made any mistake in it please suggest me.
Also In the visual force page I am trying to display the asset field value of that particular account.

THanks in advance
Prad
Hi All,

I need a field update on account page based on opportunity record types. As we have multiple record types for opportunities lets say for example A and  B. Whenever an Account has record type opportunity and aslo B record type opportunity, i need a filed update on the account page to know this. I am using below formula field but its not working

IF( Test1__r.RecordType.Id = "12345678932565", true,false)

                Please help

Thanks
Srikanth
I want to know difference between  commandButton and pageBlockButton for interview purpose.

Please suggest some important difference not the salesforce's definition.


Thanks You!

SKT
Hii All,
How can I create an user using apex code,
thanks in advance.
Hi all
I have created a Vf Page for file uploading.when i am uploading file and going to save the record its showing error

Visualforce ErrorHelp for this Page
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!save}' in component <apex:commandButton> in page newsalesconfirmation: Class.NewSalesConfirmationExtension.save: line 55, column 1

 
public class NewSalesConfirmationExtension {
    public Purchase_Order__c purchaseOrder{get;set;}
    public Transient Attachment attachment {get;set;}
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
    public NewSalesConfirmationExtension(ApexPages.StandardController controller) {
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
        
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        attachment = new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.RecordTypeId == c2RecordTypeId){
            showC1RecordType = false;
            showC2RecordType = true;
        }
        
    }
    
     public void setDefaultValues(){
        String quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c,
                    o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId];
        //system.assert(false,quote);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
    public PageReference save(){
        if(attachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
                attachment.OwnerId = UserInfo.getUserId();
                attachment.ParentId = purchaseOrder.id;
                insert attachment;
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}
----------------------------------------------------------------------------------------------

<apex:page standardController="Purchase_Order__c" extensions="NewSalesConfirmationExtension">
    <apex:sectionHeader title="Sale Confirmation Orders" subtitle="{!purchaseOrder.Name}" />
      <apex:form enctype="multipart/form-data">
        <apex:pageMessages ></apex:pageMessages>
        <apex:pageBlock title="Sale Confirmation Order Edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC1RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Pre_shipment_Inspection_required__c}" required="true" />
              
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                   
                    <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                     <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>--->
               
               
               <!--- <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>--->
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
              
               <!-- <apex:inputField value="{!purchaseOrder.PO_Uploaded__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>--->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Information" columns="2" collapsible="false" rendered="{!showC2RecordType}">
                <apex:inputField value="{!purchaseOrder.Opportunity__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Number__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.GRN_needed_for_Bill_Processing__c}"/>
                <apex:inputField value="{!purchaseOrder.Sale_Confirmation_Order_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.No_of_Days_for_collecting_GRN__c}"/>
                <apex:inputField value="{!purchaseOrder.Committed_Dispatch_Date__c}" required="true"/>
                <apex:inputField value="{!purchaseOrder.Credit_Limit__c}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Ordered_Quantity__c}"/>
                <apex:inputField value="{!purchaseOrder.CurrencyIsoCode}"/>
                <apex:inputField value="{!purchaseOrder.Customer_Price__c}"/>
                <apex:inputField value="{!purchaseOrder.Purchase_Frequency__c}" required="true" />
                <apex:inputField value="{!purchaseOrder.Bill_Submission_Period__c}"/>
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"/>
               
                <!---<apex:inputField value="{!purchaseOrder.CountAttachment__c}"/>
                <apex:inputField value="{!purchaseOrder.Try__c}"/>
                <apex:inputField value="{!purchaseOrder.New_Flash_Email_sent__c}"/>
                 <apex:inputField value="{!purchaseOrder.New_Flash_Aidc_Email_sent__c}"/>---->
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Quote Details" columns="1" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Quote__c}"/>
                <apex:inputField value="{!purchaseOrder.Company__c}"/>
                 <apex:inputField value="{!purchaseOrder.Delivery_Address__c}" required="true" />
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="New Flash Details" columns="2" collapsible="false">
                <apex:inputField value="{!purchaseOrder.Application_Area__c}"  rendered="{!showC1RecordType}"/>
                <apex:inputField value="{!purchaseOrder.Remarks__c}"/>
            </apex:PageBlockSection>
            
            <apex:pageBlockSection title="Upload Purchase Order" columns="2" collapsible="false">
                <apex:pageBlockSectionItem >
                <apex:outputLabel value="File" for="file" />
                <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
                </apex:pageBlockSectionItem>
            </apex:PageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


Class.NewSalesConfirmationExtension.save: line 55, column 1
I need to make a trigger in the background to calculate the last activity/opportunity period for this account and if the period is more than 3 months to update a field "Account Status" in the account to be idle and if less than 3 months to be active.

Please note that i have no developer experience.
I am writing a test class for the controller but it is covering only 64% of the code how i can increase the code coverage
Here is my Controller
public with sharing class propertycontrollerdetail {
public seit__Property__c ppo {get; set;}


    public propertycontrollerdetail(ApexPages.StandardController controller)
    {
       ppo = new seit__Property__c();
    }

    public pageReference SaveA()
    {
        try{
         upsert ppo;
        PageReference pageRef = new PageReference('https://itroos-dev-ed--seit.na34.visual.force.com/apex/Property');
        pageRef.setRedirect(true);
        return pageRef;  
        }
        catch(Exception ex)
        {
           ApexPages.addMessages(ex);
         system.debug(ex);
         PageReference pageRef = new PageReference('https://itroos-dev-ed.my.salesforce.com/a01/o');
        pageRef.setRedirect(true);

        throw ex;
        }
    }
}
and my test class is
@isTest
public class TestPropertyController{
  
    static testMethod void saveA(){

    Property__c pro = new Property__c( seit__Address__c = 'Lalazkhbhjkgar',seit__Description__c='sghj sjgh ',       seit__Size__c='10 Marla',seit__Size_in_sq_ft__c='12000',seit__Status__c='Sold',seit__Type__c='Residential');
insert pro;
         ApexPages.StandardController sc = new ApexPages.standardController(pro);
         Propertycontrollerdetail testAccPlan = new propertycontrollerdetail(sc);
         PageReference pageRef = Page.Property;
         pageRef.getParameters().put('id', String.valueOf(pro.Id));
         Test.setCurrentPage(pageRef);
         propertycontrollerdetail controller = new propertycontrollerdetail(sc);
         controller.SaveA();

    }
}


 
hi 
here my question is to refresh the field level under input field. 
here the problem is i am unable to refreshing the another field..
why because i am using input field ..

Please reply me with suitable approach.
Thanks in advance,
kattappa.
I have a requirement to read multiple files that will be placed on a network drive on a daily basis and update Salesforce records with the data from the file. These are csv files with each value in quotes (to handle the commas in the values).
The process should be automated. Looking for suggestions on possible ways of implementing this. Any code samples will be appreciated.
Thanks in advance.
hi 
Here my requirement is  new account is having already 2 contacts.
when ever a new contact record is created then add that contact to "New account".
 
here i have written trigger.
trigger contrig on Contact (after insert) {
  
    for(contact con:Trigger.new)   
   {
    
       account newacc=[SELECT Id,Name FROM Account WHERE Name = 'new account'];
      con.accountid = newacc.id;
    insert con;
  }
 }

thanks in advance,
kattappa
 
We have enabled the SSO settings in system and wroking fine for all users from long time.
Recently we faced the issue for only 5 users while login through single sign on and it says that ""Internal Server error" .
We tried to find the issue in all the ways but no solution .Please let me know if anybody have an idea about when the "Internal Server error" (login history message)message will be come for users while login through sso.
Hi Techies,

Hope evry one doing good. I am new to Salesforce Integraiton. Can some body help me/guide me how to start with. 
What are the best practises to learn salesforce integration. Requesting you all to give me your valuable suggestions to learn salesforce integration easily, also share your examples on salesforce integration.

Thanks in advance fellows.

Great day ahead.
Regards
Prad
Hi
How to update opportunity field with product custom field (using trigger).

   
Thanks 
Srikanth.

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.