• Agustin B
  • SMARTIE
  • 1198 Points
  • Member since 2020

  • Chatter
    Feed
  • 40
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 250
    Replies

I am attempting to complete Prevent XSS in Lightning Platform Applications.

The only feedback the challenge provides is: "It doesn't appear that you've fixed all of the merge fields to prevent cross-site scripting vectors. Please check your code again.".

This feedback is provided even if I delete all the code. I've provided what I think is the correct answer, but no dice. 

Can someone tell me what I've got wrong? I've spent more than 2 hours on this 45 minute exercise.

Code as follows:

<apex:page controller="XSS_Mitigations_Challenge" sidebar="false" tabStyle="XSS_Mitigations_Challenge__tab">
<apex:sectionHeader title="XSS Mitigations Challenge" />
<apex:form >
    <apex:pageBlock >
        <c:Classic_Error />
        <apex:pageMessages />      
        <apex:pageBlockSection title="Demo" columns="1" id="tableBlock">
            <c:codeLink type="Visualforce" namespace="" edit="true" name="XSS_Mitigations_Challenge" description="Edit this Visualforce page to perform the challenge."/>
                        
            <apex:outputText value="{!sampleMergeField1}"/>
            <!--apex:outputText value="{!sampleMergeField1}"/-->
            <!-- sampleMergeField1 is vulnerable to XSS: NO -->


            <apex:outputText value="{!HTMLENCODE(sampleMergeField2)}" escape="false"/>
            <!--apex:outputText value="{!sampleMergeField2}" escape="false"/-->
            <!-- sampleMergeField2 is vulnerable to XSS: YES -->


            <apex:outputText >
                {!sampleMergeField3}
            </apex:outputText>
            <!--apex:outputText >
                {!sampleMergeField3}
            </apex:outputText-->
            <!-- sampleMergeField3 is vulnerable to XSS: NO -->
       
       
            <script>
                document.write('{!JSENCODE(sampleMergeField4)}');
            </script>
            <!--style>
                document.write('{!JSENCODE(sampleMergeField4)}');
            </style-->
            <!-- sampleMergeField4 is vulnerable to XSS: YES -->

             
            
            {!JSINHTMLENCODE(sampleMergeField5)}
            <!--{!sampleMergeField5}-->
            <!-- sampleMergeField5 is vulnerable to XSS: YES -->
            
            <script>
                var x = '{!JSENCODE(sampleMergeField6)}';
            </script>
            <!--script>
                var x = '{!sampleMergeField6}';
            </script-->
            <!-- sampleMergeField6 is vulnerable to XSS: YES -->
            
            <apex:outputLabel value="{!JSINHTMLENCODE(sampleMergeField7)}" escape="false"/>
            <!--apex:outputLabel value="{!sampleMergeField7}" escape="false"/-->
            <!-- sampleMergeField7 is vulnerable to XSS: YES -->      


        </apex:pageBlockSection>
        <apex:pageBlockSection title="Code links" columns="1">
            <apex:outputPanel >
                <ul>
                    <li><c:codeLink type="Visualforce" namespace="security_thail" name="XSS_Mitigations_Challenge" description="Visualforce Page"/></li>            
                    <li><c:codeLink type="Apex" namespace="security_thail" name="XSS_Mitigations_Challenge" description="Apex Controller"/></li>
                </ul>
            </apex:outputPanel>        
        </apex:pageBlockSection>        
    </apex:pageBlock>          
</apex:form>              
</apex:page>

Hi,

I am trying to extract the specific portion from the values from the text field (Product name) and putting them into formula field (Actual Product) 

The formula I am using this: 
SUBSTITUTE(SUBSTITUTE(Product_Name__c ,"S.", ""),"S-", "")
However, at the end of some values I have US.01 and the formula is also parsing the values and resulting in U01 which is not desirable. Is there a way to tweak the formula that it only does that for start of the values for "S." and "S-"  Not at the end? 

Formula field                |  Text field
User-added image
Thank you
  • June 30, 2020
  • Like
  • 0
Hi, 
I am running a test class on opportunity, which is inserting opportunity line items in couple of methods and everytime its trying to insert the Opp line item I get the below error from the trigger. 
It looks like Opp line item is getting inserted but trigger is failing them.

The line number which shows in the error is again the update/insert of opp line item which is failing. 

I checked the error Attempt to dereference null object, but I see new object is instatiated whereever dml is being performed. 

I checked the UserAssignHelper.checkLineItems at line 13 which is getting values from custom settings and I see values exists there. 

Please suggest. 
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PSLR_OpportunityLineItem: execution of AfterInsert

caused by: System.DmlException: Update failed. First exception on row 0 with id 00k2i000003lJCDAA2; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PSLR_OpportunityLineItem: execution of AfterUpdate

caused by: System.NullPointerException: Attempt to de-reference a null object

Class.UserAssignHelper.checkLineItems: line 13, column 1
Class.PSLR_OpportunityLineItemHandler.updateOppOwnerBasedOnLineItemPricingType: line 122, column 1
Trigger.PSLR_OpportunityLineItem: line 50, column 1: []

Class.PSLR_OpportunityLineItemHandler.NoOfLineItem: line 28, column 1
Trigger.PSLR_OpportunityLineItem: line 42, column 1: []

 
Hello - I need help adding Account Ids to Contacts. I tried using a map but I don't have any matching keySet that will return the Id. Can I add the Ids to a list and then assign the Id from the list to a updateCt.AccountId?  If so, how can I do this without writing a different class?
 
//Query newly created Account
       List <Account> insertedAcct = [SELECT Id FROM Account WHERE Id =:insertAccounts];

//Query contact that needs the new Account Id 
        List <Contact> indClientIdList = [SELECT Id, AccountId FROM Contact WHERE Id = :clientIdList];
        
        if(indClientIdList.size() > 0){
            for(Contact updateCT : indClientIdList){
                updateCt.AccountId =   NEW ACCOUNT Id HERE );
            }
        }



 
I want to know how can I show more than 1 record of my list without getting an error.
This is my actual code:
Class:
this.AccountList = [Select  Owner.name
                                From Account
            this.target = this.AccountList.get(0);
Page:
<apex:pageBlockSection title="" collapsible="false" columns="2" rendered="{!target.Name != ''}">
<apex:outputText value="{!target.Name}"/> 
</apex:pageBlockSection>

I want to know how can I show more than 1 object without getting an error.

This is my actual code:

Class:

this.AccountList = [Select  Owner.name
                                From Account
            this.target = this.AccountList.get(0);

Page:

<apex:pageBlockSection title="" collapsible="false" columns="2" rendered="{!target.Name != ''}">

<apex:outputText value="{!target.Name}"/> 

</apex:pageBlockSection>

Hi there,

I have a object Campaign_Follow_Up_Stage__c ,on this object i have a Campaign Lookup.
* On Campaign_Follow_Up_Stage__c object, i have a status field, when i insert or update record,if status = "Planned" , It changed the Campaign Field status into "In-Progress",If if status = "Draft" , It changed the Campaign Field status into "Planned" and if status = "Compelete" , It changed the Campaign Field status into "Compelete".

I wrote this:-
trigger updateCampaignStatus on Campaign_Follow_Up_Stage__c (after Update,after insert) {
    set<Id> campIds = new set<Id>(); 
        for(Campaign_Follow_Up_Stage__c c : trigger.new){ 
         if(c.Status__c == 'Planned'){
            campIds.add(c.id);
        }     
    }
    List<Campaign> cmList = [SELECT id, status FROM Campaign WHERE id In :campIds];
     for(Campaign cm : cmList){
         cm.status = 'In Progress';
     }
     update cmList;
}



Any help appreciated!

Thanks
L.N



 
I have a apex class which is having one method with returntype wrapper class. i am binding the return type in helper in a response attribute (type is object). I want to fetch two variables i.e. id,status from response. Currently I am getting undefined error in output.
Reponse attribute in cmp:
<aura:attribute name="response" type="object"/>
Helper.js:
({ getStatusHelper : function(component, event,helper) {
var jobID = event.getParam("Pass_Result");
component.set("v.jobId", jobID); var action = component.get("c.getCalloutResponseStatus"); action.setParams({"jobId": jobID});
action.setCallback(this, function(response) { var state = response.getState();
if (component.isValid() && state === "SUCCESS") { component.set("v.response", response.getReturnValue());
**var getStatus = component.get("v.response").status; //GETTING UNDEFINED ERROR
var getJobId = component.get("v.response").id; //GETTING UNDEFINED ERROR**
}
else{ alert('Failed status call from child!!'); } }); $A.enqueueAction(action); }
})
can anyone pls help me on this issue
  • June 23, 2020
  • Like
  • 0
I've tried two bits of code now and I keep getting the error:

Challenge not yet complete in My Trailhead Playground 3
The 'challengeComplete' method in the 'UnitOfWorkTest' class has not successfully passed all tests. Ensure that you run the tests and it passes successfully before attempting this challenge again.


Here's the code I'm trying to run:

//Code attempt #2
public class UnitOfWorkTest {
    public static void challengeComplete() {
        fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(
            new Schema.SObjectType[]{
                Account.SObjectType,
                Contact.SObjectType, 
                Note.SObjectType});
        for (Integer i = 0; i < 100; i++) {
            Account acc = new Account(Name = 'TestAcc' + i);
            uow.registerNew(acc);
            for (Integer j = 0; j < 5; j++) {
                Contact c = new Contact(LastName = 'TestContact' + i + '_' + j);
                uow.registerNew(c, Contact.AccountId, acc);
                Note n = new Note(Title = 'TestNote' + i + '_' + j, Body = 'Test note body.');
                uow.registerNew(n, Note.ParentId, acc);
            }
        }
        uow.commitWork();
        System.assertEquals(100, [SELECT Id from Account].size());
        System.assertEquals(500, [SELECT Id from Contact].size());
        System.assertEquals(500, [SELECT Id From Note].size());
    }
}
/*My Original Code, attempt #1
public class UnitOfWorkTest {
    public static void challengeComplete(){
        //Create the unit of work
        fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(
            new Schema.SObjectType[]{
                Account.SObjectType,
                Contact.SObjectType,
                Note.SObjectType
            }
        );
        //Do Some Work!
        for(Integer a=[select id from account].size(); a<100; a++){
            Account acc = new Account();
            acc.Name = 'UoW Test Name' + a;
            uow.registerNew(acc);
            for(Integer c=0; c<5; c++){
                Contact cont = new Contact();
                cont.FirstName = 'James ';
                cont.LastName = acc.name + c;
                uow.registernew(cont, Contact.AccountId, acc);
                Note nt = new Note();
                nt.title = 'UoW Note #' + c;
                nt.Body = 'UoW Body ' + c;
                uow.registernew(nt, Note.ParentId, acc);
            }
        }
        //Commit the work to the database
        uow.commitWork();
        
        System.assertEquals(100, [select id from account].size());
        System.assertEquals(500, [select id from contact].size());
        System.assertEquals(500, [select id from note].size());
    }
}
*/
I'm to new to apex. 
I have a class that would allow Users from a public group (marketing group) to access records created by another user say "System Admin".

I wanted to create a test class that would create a record using the sys admin profile and check if the marketing group can have edit access to the record.

Here is my code: 
public class OpportunitySharing {
    //sharing record after creating
   public void shareAfterInsert(List<Opportunity> oppoList){
       OpportunityShare oppShare = new OpportunityShare();

       List<Group> MarketingGroup = [SELECT Id, Name FROM Group WHERE Name = 'Marketing Group'];

       for(Opportunity opp: oppoList) {
           for(Group mg : MarketingGroup) {
               
               oppShare.OpportunityId = opp.Id;
               oppShare.UserOrGroupId = mg.Id;
               oppShare.OpportunityAccessLevel = 'Edit';
               Database.SaveResult dbsr = Database.insert(oppShare, false);
           }
       }
   }
}

 
To preface my question I"m a newbie so please be patient with me I'm very new to Salesforce.

I need to populate a text field called "Account Folder Name" with one of these values Agent, Carrier, Individual, Support, Client, Prospect or Former Client.  The result of this field will be used to create our folder structure in Egnyte.

My challenge  is under the field "BenefitsGuide__RecordTypeName__c" I have two options "Account_Large_Group" and "AccountSmallGroup" that need to be broken down into "Client" or "Prospect" or "Former Client".  I have looked everywhere and the best I came up with is the following...

CASE(BenefitsGuide__RecordTypeName__c, 
"Account_Broker_Agent", "Agent", 
"Account_Brokerage_Agency", "Agent", 
"Account_Carrier", "Carrier", 
"Account_Groups_of_1", "Individual",
"Account_Individual_Family", "Individual",
"AccountSupport", "Support",

"Account_Large_Group", 
    IF(Egnyte_Group_Type__c = "Client", "Client",
    IF(Egnyte_Group_Type__c = "Prospect", "Prospect",
    IF(Egnyte_Group_Type__c = "Former Client", "Former Client", "")))

"AccountSmallGroup", 
    IF(Egnyte_Group_Type__c = "Client", "Client",
    IF(Egnyte_Group_Type__c = "Prospect", "Prospect",
    IF(Egnyte_Group_Type__c = "Former Client", "Former Client", "")))

"General"))

My problem is I can't figure out how to get past the syntax error missing ')' so any help will be appreciated.  Oh and "Egnyte_Group_Type__c" is a text field I am pulling data into from a picklist field.  If needed I can use the picklist field directly its name is "BenefitsGuide__Account_Status__c".

Thanks
  • June 17, 2020
  • Like
  • 0
trigger InvoiceTotal on Invoice_Item__c (after insert, after update) {
    set<ID> setId = new set<ID>();
    List<invoice__c> lstInvoice = new List<invoice__c>();
    
    for(Invoice_Item__c fndId :trigger.new){
        setId.add(fndId.invoice__c);
    }
    
    for(invoice__c parentInvoice :[select id, name, invoice_no__c, (select id, invoice__c, Total_Price__c, name  from Invoice_Item__c) from Invoice__c where Invoice__c.id in :setId]){
        Invoice__c Inv = new Invoice__c();
        inv.id = parentInvoice.id;
        inv.Total_amount__c =parentInvoice.Total_price__c;
        lstInvoice.add(inv);
    }
    update lstInvoice;
}
Hi and thanks in advance.

We are converting a url button to Lightning component.  I can get the url button to work in Lightning, but I don't have the control over pre populating fields etc.  I want to clear out a few fields.  This is a Clone account button which fires an Apex Class.  

The error I get when clicking the Action button is "Error while creating component for lightning component quick action [Unable to find action 'getAccount' on the controller of c:Clone]"

Please advise on where i went wrong.


I wrote a component

<aura:component controller="CloneAcctBtn" implements="force:lightningQuickActionWithoutHeader,lightning:isUrlAddressable,force:hasRecordId,lightning:hasPageReference,force:appHostable,flexipage:availableForAllPageTypes" >
    <!--This controls the display of the New RTO Quick action screen, before the New Account screen.  It supresses it.   
    <aura:html tag="style">
        .slds-backdrop {
        background: rgba(43, 40, 38, 0) !important;  
        }
        .slds-fade-in-open {
        display:none !important;
        }
    </aura:html>-->
    <aura:attribute name="acc" type="Account"/>     
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />    
         
</aura:component>

Controller:

({
    doInit : function(component, event, helper) 
    {
      var userId = $A.get("$SObjectType.CurrentUser.Id");   
      var action = component.get("c.getAccount");
      action.setParams({"accountId": component.get("v.recordId")});
      action.setCallback(this, function(response){
      var state = response.getState();   
     
      if(component.isValid() && state === "SUCCESS")
       {
        var  acc = response.getReturnValue(); 
        var createAcountEvent = $A.get("e.force:createRecord");
        var accid=component.get("v.recordId");
            
        console.log('accid-'+accid);
          //example set
          createAcountEvent.setParams({
              "entityApiName": "Account",
              "defaultFieldValues":{
          'Name': acc.sObjectInfo.Name,  
          'DataSrc__cSave' : acc.sObjectInfo.DataSrc__c, 
          'CMF_Bill_To_DUNS_Number__cSave' : acc.sObjectInfo.CMF_Bill_To_DUNS_Number__c,
          'Federal_Tax_ID_Number__cSave' : acc.sObjectInfo.Federal_Tax_ID_Number__c,
          'AccountNumberSave' : acc.sObjectInfo.AccountNumber
              }    
       });

        createAcountEvent.fire(); 
                    
        } 
        else
        {
        //write toast message replace the console.log
        helper.toastMessage('Problem getting account, response state');
        //console.log('Problem getting account, response state: ' + state);
        }
        });
        $A.enqueueAction(action);
    }
                    
 })

Class
    public with sharing class CloneAcctBtn {
@AuraEnabled
    public Account a;
    Map<String, Schema.SObjectField> m1 = Schema.SObjectType.Account.fields.getMap();
    string oldRecType;
    
    public CloneAcctBtn(ApexPages.StandardController stdController) {
        this.a = (Account)stdController.getRecord();
        oldRecType = a.RecordTypeId;
    
    }

    
    public Pagereference acctCloned(){//Account acct
        //find all record types
        List<Schema.RecordTypeInfo> infos = Schema.SObjectType.Account.RecordTypeInfos;
        Id defaultRecordTypeId;
        integer i = 0;
        
        String theId = ApexPages.currentPage().getParameters().get('id');
        system.debug(a + ' '+ theID);
        //a = [select id, name, BillingStreet from Account where id =:theId];
        
        /* query lead and then clone it */
        String soql = GrabUpdateableFieldsUtil.getCreatableFieldsSOQL('Account','id=\''+theId+'\'');
        if(Test.isRunningTest())
            System.debug('SOQL for clone: ' + soql);
        a = (Account)Database.query(soql);
        
        // Do all the dirty work we need the code
        Account clonedAcc = a.clone(false,true,false,false);
        
        //check each one
        for (Schema.RecordTypeInfo info : infos) {
            i++;
            if (info.DefaultRecordTypeMapping && info.isAvailable()) {
                defaultRecordTypeId = info.RecordTypeId;
            }
            
        }
        
        for(String fieldName : m1.keySet()) {
            if(m1.get(fieldName).getDescribe().isUpdateable()) {
                system.debug(m1.get(fieldName) + ' ' +m1.get(fieldName).getDescribe().getType() + ' '+m1.get(fieldName).getDescribe() );
                
                //get data types for each fields
                Schema.DisplayType fielddataType = m1.get(fieldName).getDescribe().getType();

                if(fielddataType  == Schema.DisplayType.Integer)
                {
                    clonedAcc.put(fieldName , 0);
                }
                else if(fielddataType != Schema.DisplayType.DateTime){
                    continue;
                }
                else if(fielddataType != Schema.DisplayType.Date){
                    clonedAcc.put(fieldName , date.valueof(system.today()));
                }
                else if(fielddataType != Schema.DisplayType.Double){
                    clonedAcc.put(fieldName , 0.0);
                }
                else if(fielddataType != Schema.DisplayType.Boolean){
                    clonedAcc.put(fieldName , true);
                }
                //else if(fielddataType != Schema.DisplayType.String){
                   // clonedAcc.put(fieldName , '');
               // }
                else
                   clonedAcc.put(fieldName , 'Some Value');
            }
        }
        //here is the default RecordType Id for the current user
        System.debug(defaultRecordTypeId);
        if(oldRecType != defaultRecordTypeId)
        {
            clonedAcc.Type__c = '';
        }
        clonedAcc.OwnerID = userinfo.getUserID();
        clonedAcc.Account_Status__c = 'Prospect';
        clonedAcc.RecordTypeId = defaultRecordTypeId;
        clonedAcc.ExternalSysID__c = ''; 
        clonedAcc.Bill_To_DUNs_Number__c = '';
        clonedAcc.accountnumber = '';
        clonedAcc.CMF_Bill_To_DUNS_Number__c = '';
        clonedAcc.CMF_Ship_To_DUNS_Number__c = '';
        
        insert clonedAcc;
        //System.assertEquals(a, clonedAcc); to do
        

        //Redirect the user back to the original page
        PageReference pageRef = new PageReference('/' + clonedAcc.id); 
        pageRef.setRedirect(true);
        return pageRef;   
        
        
    }

}

Hello,

I have a small trigger:
 

trigger SetTitleToAttachment on Attachment (after insert) { 

    
    //store the ID of the new attachment
    ID attachment;
    ID workOrder;

    
    
    for (Attachment att : Trigger.new) {
        attachment = att.ID;
        workOrder = att.ParentId;
       
        
    }
   Map<ID, SVMXC__Service_Order__c> wo =new Map<ID, SVMXC__Service_Order__c>( [SELECT ID, NAME, SVMX_PS_Ship_To_Name__c from SVMXC__Service_Order__c WHERE ID =: workOrder ]);


}


My question is: how can I access the fieds: Name and SVMX_PS_Ship_To_Name__c from this map?

I'm confused. 

The image is showing properly if i delete the renderAs attribute.

<apex:page  standardController="Opportunity" extensions="MapsTesController">
<img src="https://chuckanddons.com/media/wysiwyg/kitten_blog.jpg"    ></img>

    <img src="GoogleAPILink" />
</apex:page>

not even the first image is showing if i add renderAs="pdf"
Hi all, 

I've been attempting to implement the mentioed endpoint (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm) .   According to the docs, this usage for this endpoint is for creating records when an external ID is not provided/available.   Therefore, the ID field becomes the external ID field.   When I create a simple post request to
https://yourInstance.salesforce.com/services/data/v37.0/sobjects/Account/Id
with the following request body (I used the docs example) 
{
    "Name" : "California Wheat Corporation",
    "Type" : "New Customer"
}
I receive the below error (where ACC_EXT__c is the external ID): 
[
    {
        "message": "Required fields are missing: [ACC_EXT__c]",
        "errorCode": "REQUIRED_FIELD_MISSING",
        "fields": [
            "ACC_EXT__c"
        ]
    }
]
I was under the assumption that the point of this endpoint was that it was meant to be called when there is no external.  Would you know why this is requiring an external ID?   Is there a problem with the API? 

Thanks in advance for your help! 


 
Health status is a field whose value can be 'Healthy' or 'healthy'. So i want to use contains in my code so that in either way it should run. I am using it as shown below:

l.Health_Status__c.contains('Healthy')
l is a variable 
Hello,
I am trying to write a test class for Knowledge__DataCategorySelection.
when running the test, the test method passed but the coverage of my trigger remains at 0%.
What am I doing wrong?
Thank you.
Hermann

Apex trigger
trigger KnownErrorCatTrigger on Knowledge__kav (after insert) {
    List<Knowledge__DataCategorySelection> dataCategories = new List<Knowledge__DataCategorySelection>();
    Id knownErrorRecordTypeId = Schema.SObjectType.Knowledge__kav.getRecordTypeInfosByName().get(label.Param_Article_KE).getRecordTypeId();
    String dataGroupName = label.Param_DataCatGroupName_HCC;
    String dataCatName = label.Param_DataCategoryName_KE;
    for(Knowledge__kav kw : trigger.new )
    {
        if(kw.RecordTypeId == knownErrorRecordTypeId) {
        //Knowledge__DataCategorySelection kDataCat = KnowledgeCategoryHelperKnownError.createDataCategory(kw.Id, 'Help_Center_Categories', 'Known_Error');
        Knowledge__DataCategorySelection dataCategory = new Knowledge__DataCategorySelection();
    	dataCategory.ParentId = kw.Id;
    	dataCategory.DataCategoryGroupName = dataGroupName;
   	    dataCategory.DataCategoryName = dataCatName;
        dataCategories.add(dataCategory);
       }
    }
    insert dataCategories;

}
Test Class
@isTest

public class KnownErrorCatTrigger_Test {
    
    public static testMethod void knowledge_DataCategorySelection () {
        
        Knowledge__DataCategorySelection dataCategory = new Knowledge__DataCategorySelection();
        dataCategory.ParentId = '02o5E000000Jl01QAC';
        dataCategory.DataCategoryGroupName = 'Help_Center_Categories';
        dataCategory.DataCategoryName = 'Known_Error';
    }
}


 
Hello, I need to add a task to multiple users (in other words, 
 i need to duplicate "assigned to" and "due date" multiple times in the same task.) Is there a way to do it?

I am using a quick action-new task. The quick action is on the Account and Contact objects, and I am using it to replace the standard OOB tasks layout. 
 

Hello All!

I have been banging my head try to figure out Unknown property 'JoinedProposalCheckController.Opportunity'. I am hoping a 2nd set of eyes will see the cause.

My VF page will eventually execute when the user clicks a button on the Opportunity page, but for now I have hard-coded a value. The purpose of my VF page will be to display Opportunities with a common value in OS_Number__c and finally link to an Opportunity that needs review.

So, my problem at present is I cannot see what is causing Unknown property 'JoinedProposalCheckController.Opportunity'.

Thank you for reading and helping.

Kind regards,

Robert

 

Here's my code:

 

VFP.

<apex:page Controller="JoinedProposalCheckController" showHeader="true" sidebar="false" >  
     <apex:form id="JPForm">  
          <apex:pageBlock title="Opportunities List" >   

   			<apex:pageBlockSection >
				{!$User.FirstName} {!$User.LastName}
			</apex:pageBlockSection>
			     
            <apex:pageBlockSection >         
               <apex:pageBlockTable value="{!Opportunity}" var="op" width="100%">
                    <apex:column HeaderValue="Select">
						<apex:outputText Value="{!op.Op.Id}"></apex:outputText>
                        <apex:outputText Value="{!op.Op.Name}"></apex:outputText>
                        <apex:outputText Value="{!op.Op.Account.Name}"></apex:outputText>
                        <apex:outputText Value="{!op.Op.OS_Number__c}"></apex:outputText>
                        <apex:outputText Value="{!op.Op.Opportunity_Number__c}"></apex:outputText>
                        <apex:outputText Value="{!op.Op.Joint_Proposal__c}"></apex:outputText>   
					</apex:column>
               </apex:pageBlockTable> 
            </apex:pageBlockSection>                 
        
          </apex:pageBlock>    
     </apex:form>
</apex:page>
 

APXC.

public class JoinedProposalCheckController {

    public List<Opportunity> opptyList {get;set;}

    	public JoinedProposalCheckController() {
		   populateOpptyList();
	    }

        private void populateOpptyList() {    
           opptyList = [SELECT Id, Name, Account.Name, OS_Number__c, Opportunity_Number__c, Joint_Proposal__c   
                        FROM Opportunity 
                        WHERE OS_Number__c = '44831']; 
        }
      
        public List<Opportunity> getopptyList() {
          return opptyList;        
        }    
}
Hi everyone, I am facing a weird issue.
I have a public site with a web service that sometimes returns 526 to the one making the request and sometimes it returns 200.

Does anyone know if I need a special configuration for this endpoint being in a public site? This is what I have:

User-added image
Maybe if I play with the HTTPS option? I read this issue is about ssl but couldn't find anything on the salesforce forums.

Thanks!!
Hi everyone, I am facing a weird issue.
I have a public site with a web service that sometimes returns 526 to the one making the request and sometimes it returns 200.

Does anyone know if I need a special configuration for this endpoint being in a public site? This is what I have:

User-added image
Maybe if I play with the HTTPS option? I read this issue is about ssl but couldn't find anything on the salesforce forums.

Thanks!!
I have the list of line item from Opportuntiy
List<products__c> allProducts = [select id, name, quantity__c, price__c ,totalPrice__c from products  where id:= parentOppIdid];

In the above list i am having  multiple  product with same name and  
i want to combine the similar product as one ie combinig the similar product and adding the quantity__c ,totalPrice__c for productlineitem.

suppose list has
name=apple, quantity__c=2 , price__c= 20 , totalPrice__c = 40
name = watermelon , quantity__c=1 , price__c = 10 , totalPrice__c = 10
name = apple , quantity__c=3 , price__c = 20 , totalPrice__c = 60

I need a single list like

name = apple , quantity__c = 5 , price__c = 20 ,totalPrice__c = 100
name = watermelon , quantity__c=1 , price__c = 10 , totalPrice__c = 10

 
Hi Guys, I really hope you can help

I'm attampting to push a change (2 apex classes) from my 'Config' sandbox to the production environment.

However, when i push my change I get 2 errors, as I'm not a Salesforce developer I'm having a hard time resolving these issues.

The Code is as follows

1)
@isTest
private class BW_RevenueScheduleBatchTest{
        static testMethod void testBW_RevenueScheduleBatch(){
                Profile p;
                User u;
                Account parentAcc;

                Account acc;
                Opportunity opp;
                Profit_Centre_Split__c secondaryPcs;
                Framework__c fw;
                Sector_Head_Mappings__c sectorHeadCS;
                p = TestData.createProfile();

                u = TestData.createTestUser(p);
                                TestData.u=u;
                parentAcc=TestData.createAccount();
                sectorHeadCS = TestData.createSectorCustomSetting(u);

                acc = TestData.createAccount(parentAcc);
                fw =  TestData.createFrameWork(acc);
                opp = TestData.createOpportunity(acc.id,fw.id);
                opp.Legacy_Source_System__c='Capsule';
                update opp;
                secondaryPcs = TestData.createSecondaryProfitCentre(opp);

                    database.executeBatch(new BW_RevenueScheduleBatch());
        }
}

 



2)
@isTest (seeAllData = true) 
public class HomePageReportControllerTest{ 

static testMethod void testHomePageReportcontroller(){         
TestData.createAll();          

System.runAs(TestData.u){  
//create an opp closing in the future...
Opportunity o = TestData.createOpportunity(TestData.acc.Id, TestData.fw.Id);            o.closeDate = system.today().addDays(5);
o.Contract_start_date__c = System.today().addDays(5);            o.Latest_status_and_next_steps__c = 'updated date';
update o;       

 PageReference pageRef = Page.MyRecentDashboard;           Test.setCurrentPage(pageRef);           
HomePageReportController hprc = new HomePageReportcontroller();           system.assert(hprc.pipelineReportId != null);           system.assert(hprc.revenueReportId != null);           system.assert(hprc.winlossReportId != null);                   
 }             
 } 
}



The errors I receive are below

1) System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OpportunityTrigger: execution of AfterUpdate caused by: System.AsyncException: Future method cannot be called from a future or batch method: SubscriberHelper.evaluateOpptyRulesFuture(Set<Id>) Trigger.OpportunityTrigger: line 29, column 1: []
Stack Trace: Class.BW_RevenueScheduleBatch.execute: line 44, column 1

2) System.QueryException: List has no rows for assignment to SObject
Stack Trace: Class.HomePageReportController.getReportId: line 18, column 1 Class.HomePageReportController.<init>: line 10, column 1 Class.HomePageReportControllerTest.testHomePageReportcontroller: line 17, column 1

If anyone could kindly advise or point me in the right direction of how this can be resolved I would be extremely grateful.

Thank you

I am attempting to complete Prevent XSS in Lightning Platform Applications.

The only feedback the challenge provides is: "It doesn't appear that you've fixed all of the merge fields to prevent cross-site scripting vectors. Please check your code again.".

This feedback is provided even if I delete all the code. I've provided what I think is the correct answer, but no dice. 

Can someone tell me what I've got wrong? I've spent more than 2 hours on this 45 minute exercise.

Code as follows:

<apex:page controller="XSS_Mitigations_Challenge" sidebar="false" tabStyle="XSS_Mitigations_Challenge__tab">
<apex:sectionHeader title="XSS Mitigations Challenge" />
<apex:form >
    <apex:pageBlock >
        <c:Classic_Error />
        <apex:pageMessages />      
        <apex:pageBlockSection title="Demo" columns="1" id="tableBlock">
            <c:codeLink type="Visualforce" namespace="" edit="true" name="XSS_Mitigations_Challenge" description="Edit this Visualforce page to perform the challenge."/>
                        
            <apex:outputText value="{!sampleMergeField1}"/>
            <!--apex:outputText value="{!sampleMergeField1}"/-->
            <!-- sampleMergeField1 is vulnerable to XSS: NO -->


            <apex:outputText value="{!HTMLENCODE(sampleMergeField2)}" escape="false"/>
            <!--apex:outputText value="{!sampleMergeField2}" escape="false"/-->
            <!-- sampleMergeField2 is vulnerable to XSS: YES -->


            <apex:outputText >
                {!sampleMergeField3}
            </apex:outputText>
            <!--apex:outputText >
                {!sampleMergeField3}
            </apex:outputText-->
            <!-- sampleMergeField3 is vulnerable to XSS: NO -->
       
       
            <script>
                document.write('{!JSENCODE(sampleMergeField4)}');
            </script>
            <!--style>
                document.write('{!JSENCODE(sampleMergeField4)}');
            </style-->
            <!-- sampleMergeField4 is vulnerable to XSS: YES -->

             
            
            {!JSINHTMLENCODE(sampleMergeField5)}
            <!--{!sampleMergeField5}-->
            <!-- sampleMergeField5 is vulnerable to XSS: YES -->
            
            <script>
                var x = '{!JSENCODE(sampleMergeField6)}';
            </script>
            <!--script>
                var x = '{!sampleMergeField6}';
            </script-->
            <!-- sampleMergeField6 is vulnerable to XSS: YES -->
            
            <apex:outputLabel value="{!JSINHTMLENCODE(sampleMergeField7)}" escape="false"/>
            <!--apex:outputLabel value="{!sampleMergeField7}" escape="false"/-->
            <!-- sampleMergeField7 is vulnerable to XSS: YES -->      


        </apex:pageBlockSection>
        <apex:pageBlockSection title="Code links" columns="1">
            <apex:outputPanel >
                <ul>
                    <li><c:codeLink type="Visualforce" namespace="security_thail" name="XSS_Mitigations_Challenge" description="Visualforce Page"/></li>            
                    <li><c:codeLink type="Apex" namespace="security_thail" name="XSS_Mitigations_Challenge" description="Apex Controller"/></li>
                </ul>
            </apex:outputPanel>        
        </apex:pageBlockSection>        
    </apex:pageBlock>          
</apex:form>              
</apex:page>

trigger LogoutEventTrigger on LogoutEventStream (after insert) {
    
    LogoutEventStream event = Trigger.new[0];
    String EventjsonString = json.serialize(Trigger.new[0]);
    LogoutEventtriggerHandler.CreateLog(EventjsonString);    
    
}
Hi,

I am trying to extract the specific portion from the values from the text field (Product name) and putting them into formula field (Actual Product) 

The formula I am using this: 
SUBSTITUTE(SUBSTITUTE(Product_Name__c ,"S.", ""),"S-", "")
However, at the end of some values I have US.01 and the formula is also parsing the values and resulting in U01 which is not desirable. Is there a way to tweak the formula that it only does that for start of the values for "S." and "S-"  Not at the end? 

Formula field                |  Text field
User-added image
Thank you
  • June 30, 2020
  • Like
  • 0
Hi, 
I am running a test class on opportunity, which is inserting opportunity line items in couple of methods and everytime its trying to insert the Opp line item I get the below error from the trigger. 
It looks like Opp line item is getting inserted but trigger is failing them.

The line number which shows in the error is again the update/insert of opp line item which is failing. 

I checked the error Attempt to dereference null object, but I see new object is instatiated whereever dml is being performed. 

I checked the UserAssignHelper.checkLineItems at line 13 which is getting values from custom settings and I see values exists there. 

Please suggest. 
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PSLR_OpportunityLineItem: execution of AfterInsert

caused by: System.DmlException: Update failed. First exception on row 0 with id 00k2i000003lJCDAA2; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PSLR_OpportunityLineItem: execution of AfterUpdate

caused by: System.NullPointerException: Attempt to de-reference a null object

Class.UserAssignHelper.checkLineItems: line 13, column 1
Class.PSLR_OpportunityLineItemHandler.updateOppOwnerBasedOnLineItemPricingType: line 122, column 1
Trigger.PSLR_OpportunityLineItem: line 50, column 1: []

Class.PSLR_OpportunityLineItemHandler.NoOfLineItem: line 28, column 1
Trigger.PSLR_OpportunityLineItem: line 42, column 1: []

 
Hi Team,
Pleasehelp me below class need to write apex class.
we will appricate baest answer
Apex class:
   global static String setExperienceId(String expId) {    
        // Return null if there is no error, else it will return the error message 
        system.debug('>>>expId>>>'+expId);
        try {
            if (expId != null) {
                Site.setExperienceId(expId);               
            }
            return null; 
        } catch (Exception ex) {
            return ex.getMessage();            
        }        
    } 
 
  • June 30, 2020
  • Like
  • 0
 global void execute(Database.BatchableContext BC, List<OBJ__c> objList) {
        try{
            if(objList!= null && objList.size() > 0 ){
                delete objList;
            }
        }
        catch(Exception ex){
            System.debug('Exception');
        }
    }
Hi, 

When a record is submitted for approval, it is locked by default. I created Apex class which unlocks the record submitted for approval on the custom object Sales Order. I already checked Enable record locking and unlocking in Apex in Process Automation setting. However, record is still locked after I submitted it. Can anyone please help?
public class UnlockSOApprovalProcess{

    public static void unlockSORecord(PBSI__PBSI_Sales_Order__c soRecord) {
        Approval.UnlockResult unlockedRersult = Approval.unlock(soRecord);
        // Iterate through each returned result
        if (unlockedRersult.isSuccess()) {
            // Operation was successful, so get the ID of the record that was processed
            System.debug('Successfully unlocked Sales Order with ID: ' + unlockedRersult.getId());
        }
        else {
            // Operation failed, so get all errors                
            for(Database.Error err : unlockedRersult.getErrors()) {
                System.debug('The following error has occurred.');                    
                System.debug(err.getStatusCode() + ': ' + err.getMessage());
                System.debug('opportunity fields that affected this error: ' + err.getFields());
            }
        }
       
        
    }   
}

 
Hello - I need help adding Account Ids to Contacts. I tried using a map but I don't have any matching keySet that will return the Id. Can I add the Ids to a list and then assign the Id from the list to a updateCt.AccountId?  If so, how can I do this without writing a different class?
 
//Query newly created Account
       List <Account> insertedAcct = [SELECT Id FROM Account WHERE Id =:insertAccounts];

//Query contact that needs the new Account Id 
        List <Contact> indClientIdList = [SELECT Id, AccountId FROM Contact WHERE Id = :clientIdList];
        
        if(indClientIdList.size() > 0){
            for(Contact updateCT : indClientIdList){
                updateCt.AccountId =   NEW ACCOUNT Id HERE );
            }
        }



 
How to perform the Salesforce Developer 1 certification test in Hanoi - Vietnam? Thanks.!
I want to know how can I show more than 1 record of my list without getting an error.
This is my actual code:
Class:
this.AccountList = [Select  Owner.name
                                From Account
            this.target = this.AccountList.get(0);
Page:
<apex:pageBlockSection title="" collapsible="false" columns="2" rendered="{!target.Name != ''}">
<apex:outputText value="{!target.Name}"/> 
</apex:pageBlockSection>

I want to know how can I show more than 1 object without getting an error.

This is my actual code:

Class:

this.AccountList = [Select  Owner.name
                                From Account
            this.target = this.AccountList.get(0);

Page:

<apex:pageBlockSection title="" collapsible="false" columns="2" rendered="{!target.Name != ''}">

<apex:outputText value="{!target.Name}"/> 

</apex:pageBlockSection>

Hi there,

I have a object Campaign_Follow_Up_Stage__c ,on this object i have a Campaign Lookup.
* On Campaign_Follow_Up_Stage__c object, i have a status field, when i insert or update record,if status = "Planned" , It changed the Campaign Field status into "In-Progress",If if status = "Draft" , It changed the Campaign Field status into "Planned" and if status = "Compelete" , It changed the Campaign Field status into "Compelete".

I wrote this:-
trigger updateCampaignStatus on Campaign_Follow_Up_Stage__c (after Update,after insert) {
    set<Id> campIds = new set<Id>(); 
        for(Campaign_Follow_Up_Stage__c c : trigger.new){ 
         if(c.Status__c == 'Planned'){
            campIds.add(c.id);
        }     
    }
    List<Campaign> cmList = [SELECT id, status FROM Campaign WHERE id In :campIds];
     for(Campaign cm : cmList){
         cm.status = 'In Progress';
     }
     update cmList;
}



Any help appreciated!

Thanks
L.N



 
Hi Trigger Experts!

Could someone please help me fix this trigger?  This is part of a huge Lead trigger, and I want to insert the following script to check if a phone number is on the Lead record is referenced in another object called 'NVMStatsSF__NVM_Call_Summary__c', and if so, get the three fields, i.e. Lead Campaign, Lead DMA, and Lead Clinic, with the values that are available in the NVM Call Summary object.

I inserted this script into the master Lead trigger, and when I try to deploy it to production, I get error 
values

1   trigger LeadTrigger on Lead (before insert, before update) {
2      for (Lead thisLead : trigger.new) {
3
4   Set<string> phoneContacted = new Set<string>();
5   for(Lead thisLead : trigger.new) {
6        string formatPhone = thisLead.Phone_Contacted__c.replaceAll('[^0-9]','');
7       phoneContacted.add(formatPhone);
8       }
9   List<NVMStatsSF__NVM_Call_Summary__c> NvmSumList = new list<NVMStatsSF__NVM_Call_Summary__c>();
10
11   NvmSumList = [SELECT Id, NVMStatsSF__CLID__c, Campaign__c, DMA__c, Clinic__c FROM NVMStatsSF__NVM_Call_Summary__c                WHERE NVMStatsSF__CLID__c IN: phoneContacted];   
12  
13   List<NVMStatsSF__NVM_Call_Summary__c> thisNvmSumList = new list<NVMStatsSF__NVM_Call_Summary__c>();   
14    for (integer i = 0; i < NvmSumList.size(); i++) {
15          if (NvmSumList[i].NVMStatsSF__CLID__c == thisLead.Phone_Contacted__c) {                        
16                    thisNvmSumList.add(NvmSumList[i]);
17                    }
18                }
19                
20          if (thisNvmSumList.size() >= 1 && thisLead.Campaign__c == Null ) {
21                    thisLead.Campaign__c = thisNvmSumList[0].Campaign__c;
22                    thisLead.Clinic__c = thisNvmSumList[0].Clinic__c;
23                    thisLead.DMA__c = thisNvmSumList[0].DMA__c;
24                }
25        }
26   }

Error Message:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LeadTrigger: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.LeadTrigger: line 6, column 1: []
Stack Trace: Class.TestCaseTrigger.leadCase: line 9, column 1

By the way, the same line 6 is causing several issues on the Test Class, but I just want to fix the Trigger for now, and will worry about  Test Class later!  :)

Thank you for your helps..
Mathew