• Matthew Coke
  • NEWBIE
  • 95 Points
  • Member since 2015

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 42
    Replies
Can high-volume portal users view all custom object records if sharing is Public Read Only?

If a custom object's org-wide sharing is set to Public Read Only, does a high-volume portal (HVP) user have access to custom records created by other HVP users?  NOTE: Each portal user has its own account.

The documentation implies that HVP users in different accounts cannot access each others' custom records, regardless of the sharing settings.  Can anyone confirm that?

The custom object in question does not have any lookups to account or contact, it stands alone.
Hi,

For account detail screen, it's been identified that it is overwritten bya VF page,

apex/AccountDetailOverride?id=001190000087LKcAAM   -----This is the URL I found on account view record

But I go see the VF page code I do nto see any Edit button code or something , Still I see Edit button on record View 

User-added image

VF Page Code is :
<apex:page standardController="Account" extensions="AMindSwitchContextControllerExt" sidebar="true" showHeader="true" id="acctDetail">
    <apex:includeScript value="{!$Resource.cometd}"/>
    <apex:includeScript value="{!$Resource.jquery_cometd}"/>
    <apex:includeScript value="{!URLFOR($Resource.treeviewGrid2983, 'jquery.min.js')}" />
    <apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"/>
    <script>
        var j$ = jQuery.noConflict();
        j$("iframe").each(function(){
            j$(this).load(function() {
                j$(this).height(j$(this).contents().find("body").height() );
            });
        });
    
        function setFocusOnLoad() {}

        console.log("About to init cometd");

        var sFjQuery$ = jQuery.noConflict();

        // Connect to the CometD endpoint
        sFjQuery$.cometd.init({
          url: window.location.protocol+'//'+window.location.hostname+'/cometd/24.0/',
          requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'}
        });

        // Subscribe to the push topic
        sFjQuery$.cometd.subscribe('/topic/DiscountApprovalUpdates', function(updates) {
            console.log(updates);
            quote = updates.data.sobject;
            action = quote.Discount_Approval_Status__c;
            quoteId = quote.Siebel_ROW_ID__c;
            var message = '{"action":"' + action + '","quoteId":"' + quoteId + '"}';
            var receiver = window.open("", "Quote Preview");
            receiver.postMessage(message, "*");
            console.log(message);
        });
    
    </script>
    <chatter:feedwithFollowers entityId="{!Account.Id}"/>
    <!--<c:HoverHeader />-->
    <c:HoverHeader />
    <apex:detail relatedList="false" inlineEdit="true" showChatter="false" relatedListHover="false"/>
    
    <apex:include pageName="accountRelationViewer"/>
    <apex:relatedList list="Renewals__r" rendered="{!$ObjectType.Renewals__c.accessible}" id="Renewals"/>
    <apex:relatedList list="Contacts" id="Contacts" rendered="{!$ObjectType.Contact.accessible}"/>
    <apex:relatedList list="Addresses__r" rendered="{!$ObjectType.Address__c.accessible}" id="Addresses"/>
    
    <apex:pageBlock rendered="{!($ObjectType.Asset.accessible)}">
    <apex:outputlabel style="display:block; font-size: 1.2em; font-family: Arial,Helvetica,sans-serif; font-weight: bold;"> Products and Services </apex:outputlabel>
    <apex:outputPanel >
        <div style="display: inline-block;">
        <c:AssetRelatedList accountid="{!account.Id}" accountname="{!account.Name}"/>
        </div>
    </apex:outputPanel>
    </apex:pageBlock>
    
    <apex:pageBlock rendered="{!($ObjectType.Asset.accessible)}">
    <apex:outputlabel style="display:block; font-size: 1.2em; font-family: Arial,Helvetica,sans-serif; font-weight: bold;"> Online Subscriptions </apex:outputlabel>
    <apex:outputPanel >
        <div style="display: inline-block;">
        <c:OnlineSubscriptionRelatedlist accountid="{!account.Id}" accountname="{!account.Name}"/>
        </div>
    </apex:outputPanel>
    </apex:pageBlock>
    <apex:outputPanel rendered="{!($ObjectType.Asset.accessible)}" >
        <div >
            <c:QuoteRelatedList />
        </div>
    </apex:outputPanel>
    <!-- SFDC-964, SFDC-841: create session with invisible canvasApp prior to JSON call -->
    <apex:canvasApp applicationName="Application_v1" parameters="{canvasSource:'Start',sfdcInConsoleUI:'{!aMindSwitchContextInConsole}',discountThreshold:'{!$User.Discount_Threshold__c}'}" width="0" height="0" maxHeight="0" maxWidth="0" />
    <apex:relatedList list="Activation_Codes__r" rendered="{!$ObjectType.ActivationCodes__c.accessible}" id="ActivationCode"/>
    
    <apex:relatedList list="AccountTeamMembers" rendered="{!$ObjectType.AccountTeamMember.accessible}" id="AccountTeamMembers"/>
    <apex:relatedList list="Career__r" rendered="{!$ObjectType.Training__c.accessible}" id="Careers"/>
    <apex:relatedList list="Opportunities" rendered="{!$ObjectType.Opportunity.accessible}" id="Opportunities"/>
    <apex:relatedList list="Cases" rendered="{!$ObjectType.Case.accessible}" id="Cases"/>
    <apex:relatedList list="OpenActivities" rendered="{!$ObjectType.Task.accessible}" id="OpenActivities"/>
    <apex:relatedList list="CombinedAttachments" rendered="{!$ObjectType.NoteandAttachment.accessible}" id="NotesAndAttachment"/>
    <apex:relatedList list="ActivityHistories" rendered="{!$ObjectType.Task.accessible}" id="ActivityHistories"/>
    <!--apex:relatedList list="Account_Relationships1__r" rendered="{!($ObjectType.Account_Relationship__c.accessible && $Profile.Name == 'Master Admin')}" id="AccountRelationships" pageSize="5" -->
     
    <apex:relatedList list="Account_Owner_History__r" rendered="{!($ObjectType.Account_Owner_History__c.accessible)}" id="AccountOwnerHistory"/>
    
        <apex:relatedList list="Accounts_Management__r" rendered="{!($ObjectType.Account_Management__c.accessible)}" id="AccountManagement"/> 
    
    <apex:pageBlock title="Account History" rendered="{!$ObjectType.AccountHistory.accessible}">    
        <apex:pageBlockTable value="{!account.histories}" var="accounthistory" id="HistTable" rowClasses="odd,even" width="100%">
            <apex:facet name="footer"></apex:facet>
            <apex:column >
                <apex:facet name="header">Edit Date</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <apex:outputText value="{0,date,MM/dd/yyyy HH:mm }">
                    <apex:param value="{!accounthistory.createddate}" />
                </apex:outputText>
            </apex:column>
                <apex:column >
                <apex:facet name="header">Field</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <b><apex:outputText value="{!accounthistory.field}"/></b>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Edited By</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <apex:outputText value="{!accounthistory.createdby.name}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Old Value</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <apex:outputText value="{!accounthistory.oldvalue}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">New Value</apex:facet>
                <apex:facet name="footer"></apex:facet>
                <apex:outputText value="{!accounthistory.newvalue}"/>
            </apex:column>
         </apex:pageBlockTable>
     </apex:pageBlock>
    <apex:relatedList list="VOC_Survey_Response__r" rendered="{!$ObjectType.VOC_Survey_Response__c.accessible}" id="SurveyResponses"/> 
    <apex:relatedList list="Billing_Profiles__r" rendered="{!$ObjectType.Billing_Profile__c.accessible}" id="BillingProfile"/>
    <!-- DMD 3/30/2016 : BTBS-3911 Adobe eSignature for DPP contracts -->
    <apex:relatedList list="echosign_dev1__Agreements__r" rendered="{!$ObjectType.echosign_dev1__SIGN_Agreement__c.accessible}" id="Agreement" />
    <!-- The below is to register the links at the top on a related list to related list basis.
        pageId: the page id set in the apex:page tag
        relatedListId:  the id set in the apex:relatedList tag
        permission: boolean variable for access to the object.  true can be passed if guaranteed access (not recommended)
    -->    
    <c:HoverFooter pageId="acctDetail" relatedListId="Contacts" permission="{!$ObjectType.Contact.accessible}"/>
    <c:HoverFooter pageId="acctDetail" relatedListId="Addresses" permission="{!$ObjectType.Address__c.accessible}"/>
    <c:HoverFooter pageId="acctDetail" relatedListId="AccountTeamMembers" permission="{!$ObjectType.AccountTeamMember.accessible}"/>
    <c:HoverFooter pageId="acctDetail" relatedListId="Careers" permission="{!$ObjectType.Training__c.accessible}"/>
    <c:HoverFooter pageId="acctDetail" relatedListId="Opportunities" permission="{!$ObjectType.Opportunity.accessible}"/>
    <c:HoverFooter pageId="acctDetail" relatedListId="Cases" permission="{!$ObjectType.Case.accessible}"/>
    <c:HoverFooter pageId="acctDetail" relatedListId="OpenActivities" permission="{!$ObjectType.Task.accessible}"/>
    <c:HoverFooter pageId="acctDetail" relatedListId="NotesAndAttachment" permission="{!$ObjectType.NoteAndAttachment.accessible}"/>
    <c:HoverFooter pageId="acctDetail" relatedListId="ActivityHistories" permission="{!$ObjectType.Task.accessible}"/>
    <c:HoverFooter pageId="acctDetail" relatedListId="SurveyResponses" permission="{!$ObjectType.VOC_Survey_Response__c.accessible}"/>
    <c:HoverFooter pageId="acctDetail" relatedListId="AccountManagement" permission="{!$ObjectType.Account_Management__c.accessible}"/>
    <c:HoverFooter pageId="acctDetail" relatedListId="BillingProfile" permission="{!$ObjectType.Billing_Profile__c.accessible}"/>
    <c:HoverFooter pageId="acctDetail" relatedListId="Agreement" permission="{!$ObjectType.echosign_dev1__SIGN_Agreement__c.accessible}" />
</apex:page>

 
I read the Hierarchy Custom Settings in document.As I understand.The hierarchy logic checks the organization, profile, and user settings for the current user and returns the most specific, or “lowest,”� value.Please explain.what it  return (specific or lowest value means)?.please give real time example
 
I would like to "catch" the POST data being sent from my web browser to the salesforce servers as it is sent, and then write that information to a file. Can anyone suggest some ways of doing this? Thanks!
Hi,

Have two objects budget and expense.
The expense should be claimed towards the budget.
The expense have 2 step approval -from manager and owner.
I need to update a field in budget when an expense is approved.

Created an master detail relationship with expense as detail.
But when I login as a different user other than admin I am not able to submit any request for approval.

The error it shows is : Unable to Submit for Approval
This record does not meet the entry criteria or initial submitters of any active approval processes. Please contact your administrator for assistance.
How to solve this issue.

With regards,
   Nisha

Click here to return to the previous page.
Hi All,
I have below requirement. Please help me. I have two custom object.
    object name: Temp_product__c
    fields:Status__c(Picklist- 'Calculate price', 'remove price', 'processed','Skipped  Update')
             Product_name__c(lookup to product)\
I am creating new records in this object(Temp_product__c) using trigger when ever a product is created or updated with status either 'Clculate price' or 'remove price'
object name: entry_disc__c
    fields: offer_code__c(text)
             product_classification__c(picklist: 'connect', 'bound', 'digital')
             tier1_disc__c
             tier2_disc__c
             tier3_disc__c
            
    object name: product2 (Standard object)
    fields:   offer_code__c(text)
                item_type__c(text)
                net_price__c(currency)
                tier1_price__c(currency)
                tier2_price__c(currency)
                tier3_price__c(currency)
I want to process Temp_product__c's records using batch class with a status of either ‘Calculate Price’ or ‘Remove Price’ After each record is processed the status would be updated to “Processed” to indicate the record has been processed and if the resulting product record was updated.
  • For those Temp_product__c records with a status of ‘Remove Price Tiers’, the corresponding Product record should be updated.  The fields: tier1_price__c, tier2_price__c, tier3_price__c, should all be set to null/blank.
  • For those Temp_product__c table records with a status of 'Calculate price' pricing values will be calculated based on entry_disc__c object. This object will store discount values for tier1_disc__c, tier2_disc__c,tier3_disc__c corresponding to each offer_code__c and Product Classification. Specific users will have access to this object and will be responsible for maintaining the data in it.
Product Classification on the Product record is determined based on below logic
    
    1. if(item_type__c==c)
          connect
    2. if(item_type__c ==b)
          bound
    3. if(item_type__c==d)
          digital

Once the classification is determined, then the pricing will be calculated on entry_disc__c table.
Use the sponsor code and the product classification from the previous step to lookup the discount percent for each tier in the enrty object.
  • If no record is found, then set each of the price tiers(tier1_price__c,tier2_price__c,tier3_price__c) to null/blank on the product
  • If a record is found, then calculate each of the pricing tiers
  1. If tier1_disc__c = null, then set the tier1_price__c to null/blank, otherwise calculate price as net_price__c * (1 – tier1_disc__c)
  2. If tier2_disc__c = null, then set the tier2_price__c to null/blank, otherwise calculate price as net_price__c * (1 – tier2_disc__c)
  3. If tier3_disc__c = null, then set the tier3_price__c to null/blank, otherwise calculate price as net_price__c * (1 – tier3_disc__c)
If the Calculated price tier for all the fields are matching with the existing price tier data then skip the update and change the status of the temp record as “Skipped  Update”, otherwise update the new price tier values on the Product and change the status of the temp record to “Processed”.
BELOW IS MY CODE:
global class CalculatePrice implements Database.Batchable<sObject>{ 
    
    global database.querylocator start(Database.BatchableContext BC){
        String strStatus1 = 'Calculate price';
        String strStatus2 = 'Remove price';
        String query='';
        query ='SELECT Id, Product_Name__r.offer_code__c Product_Name__r.item_type__c,Product_Name__r.net_price__c, Product_Name__r.tier1_price__c,Product_Name__r.tier2_price__c,Product_Name__r.tier3_price__c FROM Temp_product__c where status__c=:strStatus1 or status__c =: strStatus2';
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Temp_product__c> lstprod){
       list<entry_disc__c> entryRec = new list<entry_disc__c>();
       list<Temp_product__c> tempLst = new list<Temp_product__c> ();
       map<String,String> mappd = new map<String,String>();
       set<String> sponCode = new set<String>();
       String strProdClass ='Connect,Digital,Bound';
       
       if(lstprod.size() > 0){
            for(Temp_product__c p1 : lstprod){
                  entry_disc__c entryobj = new entry_disc__c();
                  if(p1.status__c=='Calculate price'){
                      if(p1.Product_Name__r.item_type__c=='c'){
                        entryobj.product_classification__c='Connect';  
                        entryRec.add(entryobj);
                      }
                   else if(p1.Product_Name__r.item_type__c=='d'){
                       entryobj.product_classification__c='digital';
                       entryRec.add(entryobj);
                   }
                   else if(p1.Product_Name__r.item_type__c=='b'){
                       entryobj.product_classification__c='Bound';
                       entryRec.add(entryobj);
                   }
                   else{}
                }
           }
            if(!entryRec.isEmpty())
            insert entryRec;
            
            for(Temp_product__c p2 : lstprod){
                
                sponCode.add(p2.Product_Name__r.offer_code__c);
                
            }
            
             for(entry_disc__c e : entryRec){
               if(sponCode.containsKey(e.offer_code__c) && (!string.isEmpty(e.product_classification__c) && strProdClass.contains(e.product_classification__c))){
                  }   
            }
        }
    }
    
    global void finish(Database.BatchableContext BC){

    }
}
I am not able to perform calculation on entry object. Please help me. Thank ypi in advance.

   
  • April 16, 2016
  • Like
  • 0
Hi
    I am using after update on task , when ever i create new activity i should fire the trigger after update , my test class run but it cover only 44% couldnt find the reason for that. could you please help me

trigger Trigtask on Task(after update) 
{
Set<String> accids = new Set<String>();


    Set<String> taskaccid= new Set<String>();
       Set<String> acountph= new Set<String>();
           string taskacno ;
    
       for(task acc: Trigger.new) 
    {
         List<Task> accListS = [select accountid from task where accountid  IN :accids  AND CallDisposition LIKE '%Lead%'];
            if(accListS != null && !accListS .isEmpty()) 
            {
                taskacno = acc.whatid;
             taskaccid.add(acc.whatid);
           }
           }

      List<Account> accphone = [Select Id,IsPersonAccount,StrPhr_Do_Not_Call_Group_Practice__c, PersonDoNotCall,StrPhr_Lead_Qualified__c  from Account where Phone IN: taskaccid];       
      if(accphone != null && !accphone .isEmpty()) 
            {
             for(Account accph: accphone ) 
{
                              acountph.add(accph.Phone);
           }
    }
   
    if(!acountph.isEmpty()) 
    {
        List<Account> accList = [Select Id,IsPersonAccount,StrPhr_Do_Not_Call_Group_Practice__c, PersonDoNotCall,StrPhr_Lead_Qualified__c  from Account where Phone IN: acountph];        {
            for(Account acc: accList) 
            {
               if ( acc.IsPersonAccount == true && acc.StrPhr_Do_Not_Call_Group_Practice__c == False && acc.ID ==taskacno )  
            
                {
                acc.StrPhr_Do_Not_Call_Group_Practice__c=True;
                 //acc.PersonDoNotCall = True;

                                   }
                if ( acc.IsPersonAccount == true && acc.StrPhr_Do_Not_Call_Group_Practice__c == False && acc.ID !=taskacno ) 
                {
                acc.StrPhr_Do_Not_Call_Group_Practice__c=True;
                 acc.PersonDoNotCall = True;

                                   }

                                   
                         }
            update accList;
        }
    }
}

test code

@isTest 
public class Tritasktest{

    static testMethod void testMethodOne() 
    {
       
          Account accone = new Account();
        accone .Name='Test Account Two';
        accone .Phone='555555';
        accone .StrPhr_Do_Not_Call_Group_Practice__c = false;
        insert accone ;
        accone .Phone='555555';
                accone .StrPhr_Do_Not_Call_Group_Practice__c = true;
        update accone ;

        Task taskone= new task();
         taskone.whatid= accone .id;
         taskone.CallDisposition ='Leadrep';
                                    insert taskone;
        Account acctwo = new Account();
        accTwo.Name='Test Account Two';
        acctwo.Phone='555555';
        accTwo.StrPhr_Do_Not_Call_Group_Practice__c = false;
        insert accTwo;
        acctwo.Phone='555555';
                accTwo.StrPhr_Do_Not_Call_Group_Practice__c = true;
        update accTwo;

         Task tasktwo= new task();
         tasktwo.whatid= acctwo .id;
         tasktwo.CallDisposition ='Leadrep';
         insert tasktwo;   
         tasktwo.whatid= acctwo.id;
         Task t=[SELECT whatid,CallDisposition FROM Task WHERE whatid=:acctwo.id].get(0);

         tasktwo.CallDisposition='Lead';
          update tasktwo;     
          
              Account acc1 = [select Id,isPersonAccount, StrPhr_Do_Not_Call_Group_Practice__c,phone from Account where Id =: accTwo.Id LIMIT 1];
        System.assertEquals(true, acc1.StrPhr_Do_Not_Call_Group_Practice__c);  
        System.assertEquals('555555', acc1.Phone);  
        
    task acc = [select Id,whatid,accountid, CallDisposition,Account_Ph_No__c from task where whatId =: accone.Id LIMIT 1];
  
      
        System.assertEquals(acc.whatid,accone.id );
         
        



    }
    static testMethod void testMethodTwo() 
    {
        Account accOne = new Account();
        accOne.Name='Test Account One';
        accOne.StrPhr_Do_Not_Call_Group_Practice__c = false;
        accOne.Phone ='5555555555';
        insert accOne;
         

        Account accTwo = new Account();
        accTwo.Name='Test Account Two';
        accTwo.StrPhr_Lead_Qualified__c = false;
        accTwo.Phone ='5555555555';
        accTwo.StrPhr_Do_Not_Call_Group_Practice__c = false;
        accTwo.PersonDoNotCall = false;


        insert accTwo;

        accTwo.StrPhr_Lead_Qualified__c = True;
         accTwo.Phone ='5555555555';
         accTwo.StrPhr_Do_Not_Call_Group_Practice__c = True;
        
          

        update accTwo;

    }



}
Hi guys,

Am new to salesforce. I need to display Order and Order products on a vf page based on user logged-in. Both are standard objects. Order and Order products are in lookup. Help me regarding this...
  • April 12, 2016
  • Like
  • 0
Could someone help me create a trigger for Lead Conversion based on the criteria below;

Basically, I have a custom field called Email Domain in the Lead object and the Account Object.  I want Leads that have specifically have Lead Status as Open to convert to a Contact into the Account where that custom 'Email Domain' fields both match.

Hi all,
I'm fairly new to Salesforce, especially Visualforce, so this might be a rather simple problem but I can't figure it out. I'm trying to create a VF Page with a lookup field for users to select a Course__c and then pass the selected Course as a parameter to an apex method for further processing. The lookup field itself is not a problem, neither is passing a hardcoded value (here the three question marks as a string) but how can I dynamically assign the selected value from the lookup to my parameter?
Thank you

VF-Page:
<apex:page controller="mycontroller">  
    <apex:form >
        <apex:inputField label="Find a Course" id="theLookup" value="{!Firstname.Course__c}"/>
        <apex:commandButton value="GO" action="{!processButtonClick}" rerender="hiddenBlock">
            <apex:param name="myCourse"
                value="???"
                assignTo="{!myCourse}"/>
        </apex:commandButton>
        <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public with sharing class mycontroller {
    public Course__c myCourse {
        get;
        set {
            myCourse = value;
        }
    }
    public Course_Group__c getFirstname(){
        return new Course_Group__c();
    }
    public PageReference processButtonClick() {
        System.debug('nickName: '+myCourse);
        // here I'd call my apex method with the selected Course as parameter
        return null;
    }
}

Hi,

We've built a controller that we use for our custom object that just allows us to show the content in a visualforce page, slightly different to a standard Salesforce layout. 

Everything seems to work perfectly until we start to introduce lookup fields to the account because the user will always create a new custom object Erad__c from the account the value will always be populated, however when we reference this field just in the same way as a text or number field the value isn't stored. We are relatively new to this sort of thing so any advice that could be offered would be appreciated.

I'm guessing that we need to store the value in the controller correctly and refernce back to the visualforce page but we're unsure on how to exactly go about it.

Visualforce page
<apex:page standardController="Erad__c" extensions="insertnewrecordController">

Hello {!$User.FirstName}!    
   
   <p>You are viewing the Erad model. Please enter the Relationship grade below based on the image and the date your assesment was made.</p>

<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel >Account</apex:outputLabel>
<apex:inputField id="Account" value="{!Erad__c.Account__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Relationship Type</apex:outputLabel>
<apex:inputField id="RelationshipType" value="{!Erad__c.Relationship_Type__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Date Completed</apex:outputLabel>
<apex:inputField id="DateCompleted" value="{!Erad__c.Date_Completed__c}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton id="Save" action="{!Save}" value="Save"/>
<apex:commandButton id="Cancel" action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
<apex:image url="{!$Resource.Erad}" width="500" height="500"/>
</apex:page>

Controller
 
public class insertnewrecordController{
public erad__c cds{get; set;}
public erad__c setcds(erad__c op){
this.cds=op;
return cds;
}
public insertnewrecordController(ApexPages.StandardController controller) {
cds=new erad__c();
}

public pagereference Save(){

erad__c cd = new erad__c();
cd.Account__c=cds.Account__c;
cd.Relationship_Type__c=cds.Relationship_Type__c;
cd.Date_Completed__c=cds.Date_Completed__c;
insert cd;
Pagereference pg = new Pagereference('/' + cd.id);
pg.setredirect(true);
return pg;


}
 
}

Thanks,

Snita
Hi,

We are looking to use Salesforce for a bespoke purpose, whereby we have two objects - one with live orders ('Live') and one with archived orders ('Archived'). We would like to add a formula to the 'Live' object which looks up the item ID in the 'Archived' object and returns the lowest price that is listed. This will help us to find the best price that has been paid for a particular item.

Thanks in advance.
Hi Friends
The following is my Apex class i have written test class for this, i coverd upto 59% i want to make it increase. can you help me to fulfill this.
 
public class FormCurriculumController { 
  

public Purchase_Order__c curriculum {get; set;}
public Boolean privacy {get; set;}
public Boolean saved {get; set;}
public String styleClass {get; set;}
// Allegato
public Transient Blob resume {get; set;}
public String contentType {get; set;}
public String fileName {get; set;}
      
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;


//ublic FormCurriculumController () {
    //curriculum = new Purchase_Order__c();
    //saved = false;
//}

  public FormCurriculumController(ApexPages.StandardController controller) {

        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        curriculum= new Purchase_Order__c();
        curriculum= (Purchase_Order__c)controller.getRecord();
         
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
       
        if(curriculum.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(curriculum.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);     
        curriculum.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        curriculum.Quote__c = quote.id;
        curriculum.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            curriculum.RecordTypeId = c1RecordTypeId;
        }
        else {
            curriculum.RecordTypeId = c2RecordTypeId;
        }
    }

    


public PageReference save() {
    try {
        // Validazione effettuata qui perchè il required sull'inputCheckbox non è utilizzabile
        if (!privacy) {
        
            ApexPages.Message reqMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Please upload recent Purchase Order  before saving the record');
            ApexPages.addMessage(reqMsg);
            return null;
        }

        // Inserisce il record
        
       
        
        
        insert(curriculum);
        // Inserisce l'allegato
        if (resume != null) {
            Attachment attach = new Attachment();
            attach.Body = resume;
            attach.Name = fileName;
            attach.ContentType= contentType;
            attach.ParentId = curriculum.id;                
            try {
                insert(attach);
                return new PageReference('/'+curriculum.id);

            } catch (Exception ex) {
                // TODO fare il roolback dell'inserimento del curriculum?

                ApexPages.addMessages(ex);
                return null;
            }                    
        }

        //Papagni 03/09/2013 - update curriculum per fare scattare il trigger di after che invia la mail
        update curriculum;

        saved = true;

    } 
    catch(Exception ex) {
        ApexPages.addMessages(ex);  
    }
    return null;   
}
}
@IsTest
public class TestFormCurriculumController  
{
static testMethod void TestMethodFormCurriculumController  ()
{

        account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        Quote__c qt=new Quote__c(Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C1'];
        
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
      
       
        insert sco;
    
         test.startTest();
         PageReference pageRef = Page.FormCurriculumController ;
         Test.setCurrentPage(pageRef);
         ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(sco);
         
         ApexPages.currentPage().getParameters().put('Id',sco.id);
         FormCurriculumController  objMyController= new FormCurriculumController  (sc);
         
         
         
         
         
         
         /*ApexPages.currentPage().getParameters().put('Id',emp.id);
            ApexPages.currentPage().getParameters().put('setDefaultValues','true');
            ApexPages.currentPage().getParameters().put('id',sco.id);
           
            ApexPages.StandardController stdLead = new ApexPages.StandardController(sco);
            NewSalesConfirmationExtension objMyController  = new NewSalesConfirmationExtension (stdLead);*/
            objMyController.save();
            
         
        test.stopTest();
        
        
        }
static testMethod void TestMethodFormCurriculumController1()
{

 account a=new account(name='test',Region__c='East');
        insert a;
        
        Master_Product__c mp=new Master_Product__c(name='test name',Product_Code__c='c2');
        insert mp;
        
        contact c=new contact(firstname='Meenakshmi',lastname='Goswami',Designation__c='Developer',Accountid=a.id);
        insert c;


        Opportunity2__c op=new Opportunity2__c(Name='test1',Account__c=a.id,Master_Product__c=mp.id,Technical_Bid_date__c=date.Today(),Type_of_Business__c='Regular',Contact_Person__c=c.id);
        insert op;
     
        Opportunity_Product_Detail__c opd=new Opportunity_Product_Detail__c(Opportunity__c=op.id,Company__c=a.id,Quantity__c=10,Make__c='Datalogic-Barcode Scanner', Model__c='S4M 203 Dpi');
        insert opd;
        
        RecordType quoteRt = [Select id,name from RecordType where SobjectType='Quote__c' and Name='C2'];
        
        Quote__c qt=new Quote__c(RecordTypeId=quoteRt.id,Opportunity_Product_Detail__c=opd.id,Basic_Price_per_1000__c=100,Basic_Price_Each_item__c=200,Purpose_of_Sales__c='SEZ',Declaration_form_be_provided__c='No');
        insert qt;
        
        Quote__c qt1=[select Quantity_formula__c from Quote__c where id=:qt.id];
        system.debug('--------Quote quantity--------'+qt1.Quantity_formula__c );
        
        RecordType rt = [Select id,name from RecordType where SobjectType='Purchase_Order__c' and Name='C2'];
        
        Purchase_Order__c sco=new Purchase_Order__c(RecordTypeId=rt.id,Quote__c=qt.id,Opportunity__c=op.id,Sale_Confirmation_Order_Date__c=date.Today());
        sco.Sale_Confirmation_Order_Number__c='100';
        insert sco;
        
         test.startTest();
            //ApexPages.currentPage().getParameters().put('id',sco.id);
            ApexPages.currentPage().getParameters().put('setDefaultValues','true');
            ApexPages.currentPage().getParameters().put('quoteId',qt.id);
            ApexPages.StandardController stdLead = new ApexPages.StandardController(sco);
            FormCurriculumController  objMyController  = new FormCurriculumController (stdLead);
           
            objMyController.attach.body=bodyBlob ;
           
            
            objMyController.save();
            
          
        
        test.stopTest();
        
        }
}


 
Please Don't want to used third party app and application .i want to develop look like and worked as shopify app

please help me
I have to check that the record exist in view List or not. So for this i wrote the following code for checking that records exist in list view or not.

List<sObject> sobjectList=[select Name,Id from TestObj where Id='a0gG000000B8W2HIAV']; 
String query = 'Select Name from TestObj LIMIT 1'; 
ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(Database.getQueryLocator(query)); 
List<System.Selectoption> ListViewList=ssc.getListViewOptions(); 
set<SObject> testset=new set<SObject>(); 
List<sObject> listChildObject=null; 
for (System.Selectoption selopn : ssc.getListViewOptions()){ 
    string viewid,viewlabel; 
    viewid=selopn.getValue();
    viewlabel=selopn.getlabel(); 
    ssc.setSelected(sobjectList); 
    ssc.setFilterId(viewid); 
    testset.addAll((List<sObject>)ssc.getSelected()); 

System.debug('testset-'+testset);

This above code is returning the testset is empty. Event this record exist in the list view of this user. But if i change the sequence like following:
ssc.setFilterId(viewid);
ssc.setSelected(sobjectList);
Now it will set records in each list view even though that records is not exist for this list view.
Actually i want to check that specific records exist in list view or not. I do not know which is best way to do in salesforce without iterating all records and checking.
Can high-volume portal users view all custom object records if sharing is Public Read Only?

If a custom object's org-wide sharing is set to Public Read Only, does a high-volume portal (HVP) user have access to custom records created by other HVP users?  NOTE: Each portal user has its own account.

The documentation implies that HVP users in different accounts cannot access each others' custom records, regardless of the sharing settings.  Can anyone confirm that?

The custom object in question does not have any lookups to account or contact, it stands alone.
I have a vfp button that redirects to a standard page on a custom object which is child object of a master object. Now the condition is, on clicking of the button it would take user to a new record insert screen and users can insert their record. However if there is already a record in the child object, instead of going to the new screen it would take user to detail page on click of that button. 

Can anyone please help me to use this functionality in one button. Right now it goes to the new screen only. 

<apex:pageBlock title="Inferno:" >
            <apex:pageBlockSection >    
                <apex:outputPanel >
                    <apex:outputLabel />
                    <apex:outputLabel />
                    <apex:outputText ><b>Inferno Page: </b></apex:outputText>
                    <apex:commandButton value="Inferno Screen" oncomplete="window.open('/a1a/e?{!$Label.Inferno_ID}={!Clover__c.Name}&{!$Label.Inferno_ID}_lkid={!Clover__c.Id}&retURL=%2F{!Clover.Id}','_parent')"  />  </apex:outputPanel>
            </apex:pageBlockSection>


Clover is the master object. 
  • April 11, 2016
  • Like
  • 0
Hello,

I am just getting started with using salesforce and would like to get some assistance with an issue I can not figure out.  

I have a visual force page that I created that is tied to a button on the page so that when they click the button they get a custom edit screen for that record. However, I am trying to figure out how I would go about having a default value applied to one of the fields once they reach the visual force page.
I hit some combination of key strokes and did something to an Apex class. (I think I saw a message on the screen asking if I wanted to delete the file, but I'm not certain.) Now when I try to open it I get an error saying the file doesn't exist. But when I try to create an new version I can't, because I get a message saying it already exists. 

Repeat as necessary.

This file is part of a Trailhead tutorial, so it has to have a specific name or I can't evaluate my work, so have to use the name as assigned.

Ideas?
Gooda day. I encountered the following exception error while running unit test:
"Failed to enqueue tests.: Unknown Exception"
My guess it is related to the daily limit of test classes to run..
May you confirm if this is the case, and if 'Yes' how can i override this. I use Sandbox, and don't have many options.
Thank you in advance.
 
  • April 11, 2016
  • Like
  • 0
Is there a way for me to find out if we are currently using a self signed certificate with any of our SFDC applications?  I can see that we created one  (or someone created one for us) a couple of years ago.  I received a notification that it will soon be expiring but I'm not aware of us actually using it for anything.
I'm trying to use Data Import wizard to update existing contacts but I'm receiving this error message. 'Your import failed: Import for object Account did not succeed. Error received - null'. I have just three columns in my import file, namely Contact ID, Contact Owner and SDR owner(custom field). What am I doing wrong?
Thanks
Hi everyone,
I tried to create a class to get executed once a year:
global class CalculOnAccount implements Database.Batchable<sObject>{
    global Database.QueryLocator start(Database.BatchableContext BC) {
       String query = 'SELECT field1__c,field2__c, cal__c FROM Account';
       return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Account> scope) {
         for(Account a : scope)
         {
             a.cal__c= ((a.field1__c- a.field2__c)*100 )/(a.field2__c);        
         }
         insert scope;
    }  
     
    global void finish(Database.BatchableContext BC) {
    }
}


My questions are:
How to schedule this to get executed in december each year for example? And what I want also is, depending on the result of cal__c, another field in Account will get updated, where I should put this treatment part? in the finish() ?
Thanks in advance
Salesforce's Apex language has a data structure for storing key/value pairs - maps. It's a pretty powerful structure, allowing you to store any two data type, including SObjects (User, Case, Opp, Etc.) as the key or value. They are not easy or practical to sort, however. I decided a double LinkedList would be prefect for my situation, but soon found that nobody had ever done a LinkedList in Apex. (At least one they had posted on the internet). I decided to implement my own double link list. There are methods to add/delete/getSize/sort, as well as an add in order method which is especially useful. The SNode class can store ANY SObject, as well as an int. It would be relatively simple to modify this to store any datatype you wish. 

All of the code will be continually updated here - https://github.com/iamjake648/ApexLinkedList. Feel free to submit pull requests as well! I'll post the current code below. 
 
/**
 * LinkedList - Written by Jacob Schultz 13.4.16
 * A simple double linked list class written in apex
 * This LL allows you to store SObjects and values/weights, and then add
 * them in order to a list and keep them sorted - unlike a map.
 * 
 * #TODO: Methods
 * -Merge Sort
 * -Delete by Object
 * -Delete by Value
 * 
 * This is still under development, and is subject to change.
 * This could also be easily modified to store Lists of SObjects
 */
public class LinkedList {
    
    private SNode head;
    private Integer size; 
    private SNode tail;
    /**
     * Constructor - Creates a new Linked List
     */
    public LinkedList(){
        this.head = null;
        this.size = 0;
    }
    
    /**
     * addToList - Creates a new SNode from an SObject and value,
     * and then adds it to the list NOT IN ORDER, just adds to the end.
     * @param SObject obj - Any SObject (User, Case, Opp, etc.)
     * @param Int value - A weight or index to give the SObject 
     */
    public void addToList(SObject obj, Integer value){
        //Create a new SNode
        SNode n = new SNode(obj, value);
        Snode temp = this.head;
        
        //First Item in the List
        if (temp == null){
            head = n;
        } else {
            //Walk to the end of the list
            while(temp.getNext() != null){
                temp = temp.getNext();
            }
            //Add to the end of the list
            temp.setNext(n);
            n.setPrevious(temp);
        }
        //Increase the size of the list
        this.size++;
    }
    
    /**
     * deleteAtIndex - Deletes an SNode at a given Index
     * Walks down the list until it reaches the index provided, 
     * then deletes the SNode and retains list order. 
     * @param Int i - Index to delete at 
     */
    public void deleteAtIndex(Integer i){
        //Make sure that index is in the list
        if (i < getSize()){
            SNode temp = this.head;
            Integer c = 0;
            //Walk down the list to the index
            while (c < i){
                c++;
                temp = temp.getNext();
            }
            
            SNode toDelete = temp;
            //Remove from list by changing the two nodes around it
            toDelete.getPrevious().setNext(toDelete.getNext());
            toDelete.getNext().setPrevious(toDelete.getPrevious());
            //Set the old objects to null
            temp = null;
            toDelete = null;
        } else {
            System.debug('Unable to delete at this index.');
        }
    }
    
    /**
     * addInOrder - Creates a new SNode and adds it to the list in order
     * This allows the list to remain sorted, without
     * ever calling a sort method. 
     * @param SObject obj - Any SObject (User, Case, Opp, etc.)
     * @param Int value - A weight or index to give the SObject
     */ 
    public void addInOrder(SObject obj, Integer value){
        SNode n = new SNode(obj, value);
        Snode temp = this.head;
        
        //First Item in the List
        if (temp == null){
            head = n;
        } else {
            Integer depth = 0;
            //Walk down the list
            while (temp.getNext() != null && temp.getValue() < value){
               temp = temp.getNext();
               depth++;
            }
            //If the value is less than the head
            if (depth == 0){
                //Add after head
                if (n.getValue() > temp.getValue()){
                    n.setPrevious(temp);
                    n.setNext(temp.getNext());
                    temp.setNext(n); 
                //New Head
                } else {
                   n.setNext(temp);
                   temp.setPrevious(n);
                   this.head = n;
                }
            } else {
                //Adding in the middle
                if (temp.getNext() != null){
                    addToListInOrder(n, temp);
                //Adding at the end
                } else {
                    if (value > temp.getValue()){
                        //Adding at the end
                        temp.setNext(n);
                        n.setPrevious(temp);
                    } else {
                        //Add before the end
                        addToListInOrder(n, temp);
                    }
                }
            }
        }
        //Increase the size
        this.size++;
    }
    
    
    
    /**
     * addToListInOrder - A simple helper method used by the addInOrderMethod
     * This helper method handles reassociating the relationships
     * when adding between two SNodes in the list.
     */ 
    private void addToListInOrder(SNode n, SNode temp){
         temp.getPrevious().setNext(n);
         n.setNext(temp);
         n.setPrevious(temp.getPrevious());
         temp.setPrevious(n);
    }
    
    /**
     * debugList - Prints the List to the salesforce Dev Console
     * Should be used when debugging the list
     */ 
    public void debugList(){
        SNode temp = this.head;
        Integer i = 0;
        System.debug('List' + i + ' : ' + temp.getValue() + ' ' + temp.getObject());
        while (temp.getNext() != null){
            temp = temp.getNext();
            i++;
            System.debug('List' + i + ' : ' + temp.getValue() + ' ' + temp.getObject());
        }
        System.debug('================================================================');
    }
    
    
    public Integer getSize(){
        return this.size;
    }
    
    /**
     * convertToList
     * This method converts a LinkedList to a stanard
     * salesforce list. Only SObject data is presevered,
     * value is dropped.
     */
    public List<SObject> convertToList(){
        List<SObject> l = new List<SObject>();
        SNode temp = this.head;
        //Walk the linkedlist and add every item to a apex list
        while (temp.getNext() != null){
            l.add(temp.getObject());
            temp = temp.getNext();
        }
        return l;
    }
    
    /**
     * convertToListDesc 
     * This method converts a LinkedList to a standard Apex
     * list, and then loops through backwards, so the larger 
     * objects are returned first.
     */
    public List<SObject> convertToListDesc(){
        List<SObject> l = new List<SObject>();
        SNode temp = this.head;
        //Walk the list and add all objects to a list
        while (temp.getNext() != null){
            l.add(temp.getObject());
            temp = temp.getNext();
        }
        
        List<SObject> ld = new List<Sobject>();
        //Start at the end and walk backwards
        for (Integer i = l.size()-1; i >=0; i--){
            ld.add(l.get(i));
        }
        return l;
    }
    
    /**
     * bubbleSort - A simple method to sort the linkedList
     * Bubble sort has a runtime of n^2 where n is the number of elements.
     */ 
    public void bubbleSort(){
        //Tracker variable to check if the list has been sorted
        boolean done = false; 
        while (!done) {
            //Temp node to walk the list
            SNode temp = head;
            done = true;
            //Loop the list
            for (Integer i = 0; i < getSize() -1; i++){
                //Check the current node and the next node's value
                if (temp.getNext().getValue() < temp.getValue()) {
                    //If next is less, than swap them
                    swap(temp, temp.getNext());
                    done = false;
                }
                //Continue down the list
                temp = temp.getNext();
            }
        }
    
    }
    
    /**
     * swap - Used by bubble sort to swap node values objects.
     */ 
    private void swap(SNode a, SNode b){
        //Temp variables to store a's values. 
        Integer i = a.getValue();
        SObject s = a.getObject();
        //Switch the values
        a.setValue(b.getValue());
        a.setObject(b.getObject());
        b.setValue(i);
        b.setObject(s);
    }
    
    public boolean isEmpty(){
        if (getSize() > 0){
            return false;
        } else {
            return true;
        }
    }
    
}
 
/**
 * SNode - Written by Jacob Schultz 13.4.16
 * 
 * A simple node class used by the Apex Linked List class.
 * This node will hold any SObject (User, Opp, Case, Etc.)
 * It will also hold a value/weight/index - whatever int you would like
 * Since the LinkedList is a doubly linkedlist there are also fields
 * for the next and previous node.
 * 
 */
public class SNode {
    
    private SObject obj;
    private Integer value;
    private SNode previous; 
    private SNode next;
    
    public SNode(){
        this.obj = null;
        this.value = 0;
        this.previous = null;
        this.next = null;
    }
    
    public SNode(SObject obj, Integer value){
        this.obj = obj;
        this.value = value;
    }
    
    public SObject getObject(){
        return this.obj; 
    }
    
    public Integer getValue(){
        return this.value;
    }
    
    public void setObject(SObject obj){
        this.obj = obj;
    }
    
    public void setValue(Integer i){
        this.value = i;
    }
    
    public void setNext(SNode n){
        this.next = n;
    }
    
    public void setPrevious(SNode p){
        this.previous = p;
    }
    
    public SNode getPrevious(){
        return this.previous;
    }
    
    public SNode getNext(){
        return this.next;
    }
}