• Gaurav Jain 7
  • NEWBIE
  • 180 Points
  • Member since 2014
  • Salesforce Consultant

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 36
    Replies
Hello,
I have a button on my page which runs a VF Page with an extension to my controller. It works to press the button and it produces the EchoSign Agreement as directed. However, the page it goes to when I click the button is a blank page. I would like to redirect it to the Id of the record I just created upon pressing the button. Basic outline of code below. So how can I get a void method to redirect to the ID of the record it just created?
public void SendPdf(){
//reference PDF Creator VF Page
pageReference pdfPage = Page.ContactPDF;
pdfPage.getParameters().put('Id',getid);
blob pdfBody;
pdfBody = pdfPage.getContentAsPDF();
          
// Build Echosign agreement record
echosign_dev1__SIGN_Agreement__c agreementRec = new echosign_dev1__SIGN_Agreement__c();
agreementRec.Name = 'Credit Info Release for: ';
//other variables entered here
insert agreementRec;

// insert the pdf as an attachment
attachment pdfFile = new attachment();
pdfFile.isPrivate = false;
pdfFile.body = pdfBody;
pdfFile.parentId = agreementRec.id;
pdfFile.Name = 'Agreement.pdf';
insert pdfFile;
}

 
Hello,
How is discount calculated in quote and is it standard ?
 
Hello All,

I want to know how to write Javascript in formula field. 
Something similar to this blog: https://sfdc-gyaan.rhcloud.com/2014/04/referencing-javascript-file-from-static-resources-in-formula-fields/

I have a formula field. When clicked on it, I want to perform an action using JS.
HYPERLINK("javascript:alert('Hello World! - Formula Field');var html_doc = document.getElementsByTagName('head')[0];var js = document.createElement('script');js.setAttribute('type','text/javascript');js.setAttribute('src','/resource/********/HelloJS');html_doc.appendChild(js);js.onload= function() { sayHelloFromAnotherJS(); }; ","_self")

And then, I get this error:

Error: Incorrect argument value for function 'HYPERLINK()'. Javascript is not allowed.
Can anyone help me here? 
Fairly simple, I am just too new to custom objects/triggers/apex.

Basically a field in the opportunity that shows the number of Products that are in the opportunity.

IE for the screenshot attached, the field Opportunity Product Count = 3
User-added image
Hello,
SSN number format in Visualforce page using Jquery or Javascript to Mask all
characters with (XXX-XX-XXXX)

Can anyone help me on this?

Thank you.
Hi All,

Unable to pass App Logic Vulnerability Prevention -- Prevent Open Redirects in Your Code module:

please see the below code:
 
public PageReference save(){
        PageReference savePage;
        if (Schema.SObjectType.Resource_Type__c.isCreateable()){
            try{
                insert rtype;
                String completion = ApexPages.currentPage().getParameters().get('finishURL');
                if(completion.startsWith('/')){
                      completion.replaceFirst('/','');
                      savePage = new PageReference('/'+completion);
                }
                else
                {
                   savePage = new PageReference(completion); 
                }
                savePage.setRedirect(true);
                return savePage;
            }catch (exception e){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'Unable to update requisitions.  Exception: ' + e.getMessage()));
                return null;
            } 
        }else{
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'You do not have permission to update requisitions'));
            return null;
        }
    }

Thanks in advance
I'm doing the Create a Satisfaction Survey Project and have hit this problem in my existing trailhead org and a brand new dev org that I've just created:

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: CENZTETL
Hi,

I an getting below error:

Challenge Not yet complete... here's what's wrong: 
The 'accEdit' Lightning Component does not appear to be checking if 'v.recordSaveError' is true.

accEdit.cmp
 
<aura:component implements="flexipage:availableForRecordHome, force:hasRecordId"> <!--inherit recordId attribute-->

<aura:attribute name="record" type="Object" />
<aura:attribute name="accountRecord" type="Object" />
<aura:attribute name="recordSaveError" type="String" />

<force:recordData aura:id="recordEditor"
    layoutType="FULL"
    recordId="{!v.recordId}"
    targetError="{!v.recordSaveError}"
    targetRecord="{!v.record}"
    targetFields ="{!v.accountRecord}"
        fields="Name"          
    mode="EDIT" />

    <!-- Display a lightning card with details about the record -->
    <div class="Record Details"> 
        <lightning:card iconName="standard:account" title="{!v.accountRecord.Name}" >
            <div class="slds-p-horizontal--small">
                <p class="slds-text-heading--small">
                    <lightning:formattedText title="Billing State" value="{!v.accountRecord.BillingState}" /></p>
                <p class="slds-text-heading--small">
                     <lightning:formattedText title="Billing City" value="{!v.accountRecord.BillingCity}" /></p>
            </div>
        </lightning:card>
    </div>
    <br/>

    <!-- Display an editing form -->
    <div class="Record Details">
        <lightning:card iconName="action:edit" title="Edit Account">
            <div class="slds-p-horizontal--small">
                <lightning:input label="Account Name" value="{!v.accountRecord.Name}"/>
                <br/>
                <lightning:button label="Save Account" variant="brand" onclick="{!c.handleSaveRecord}" />
            </div>
        </lightning:card>
    </div>


    <aura:if isTrue="{!not(empty(v.recordSaveError))}">
		<br />

        Error: <ui:outputText value="{!v.recordSaveError}"/>

    </aura:if>
</aura:component>


accEditcontroller.js
({
    handleSaveRecord: function(cmp, event, helper) {
        cmp.find("recordEditor").saveRecord($A.getCallback(function(saveResult) {
            if (saveResult.state === "ERROR") {
                var errMsg = "";
                // saveResult.error is an array of errors, 
                // so collect all errors into one message
                for (var i = 0; i < saveResult.error.length; i++) {
                    errMsg += saveResult.error[i].message + "\n";
                }
                cmp.set("v.recordSaveError", errMsg);
            } else {
                cmp.set("v.recordSaveError", "");
            }
        }));}
})

 
I am trying to send End Point URL to SAP PO system but URL needs credentials

Please advise
Create contact and hobby reports
Create the three hobby-related custom reports as detailed in the Business Requirements section above. Use the same custom Report Type as the basis of these custom reports. Set the Accounts object as the top level of the Report Type.

"Challenge Not yet complete... here's what's wrong:  The 'Contacts by Hobby and Rating' report is not configured correctly."

 
Can anyone help me to fire the below trigger on a specific record type only.
I have record type of "Business Organization (Mastered)" and below trigger should fire only on the mentioned record type.

trigger PreventDuplicateContact on Contact (before insert,before update) {
    
    if(trigger.isInsert || trigger.isUpdate)
    {
        Map<Id,List<Contact>> accMap = new Map<Id,List<Contact>>();
        List<Contact> contactList;
        
        for(Contact c: [Select Id,Email,accountId from Contact]){
            if(accMap.containsKey(c.accountId)){   
                accMap.get(c.accountId).add(c);
            }
            else{
                contactList = new List<Contact>();
                contactList.add(c);
                accMap.put(c.accountId,contactList);
            }       
        }
        
        for (Contact c : Trigger.new)
        {
            if(accMap.containsKey(c.accountId)){
                for(Contact con : accMap.get(c.accountId)){
                    if(c.Email == con.Email){
                        c.Email.addError('Contact with this email address already exists');
                    }
                }
            }
        }
    }
}
I'm doing the Create a Satisfaction Survey Project and have hit this problem in my existing trailhead org and a brand new dev org that I've just created:

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: CENZTETL
Hi Everyone!

When trying to veryfy the first challenge in "Upload Flag Images into Salesforce Analytics" I am receiving the following error,

Challenge Not yet complete... here's what's wrong: 
Could not find 'Analytics Cloud Platform' licenses. Please check instructions to login to Wave enabled org.

This is a brand new org. and setup as outlined on the trail.
The org. is connected and lunched - I have repeated this multiple times.

Permission Set Licenses

The error is talking about "Analytics Cloud Platform" licenses which indeed do not exist the licenses available here are "Analytics Cloud Explorer & Analytics Platform" which are Permission Set Licenses.

Any useful suggestion here is highly appricated.
Hi,

I an getting below error:

Challenge Not yet complete... here's what's wrong: 
The 'accEdit' Lightning Component does not appear to be checking if 'v.recordSaveError' is true.

accEdit.cmp
 
<aura:component implements="flexipage:availableForRecordHome, force:hasRecordId"> <!--inherit recordId attribute-->

<aura:attribute name="record" type="Object" />
<aura:attribute name="accountRecord" type="Object" />
<aura:attribute name="recordSaveError" type="String" />

<force:recordData aura:id="recordEditor"
    layoutType="FULL"
    recordId="{!v.recordId}"
    targetError="{!v.recordSaveError}"
    targetRecord="{!v.record}"
    targetFields ="{!v.accountRecord}"
        fields="Name"          
    mode="EDIT" />

    <!-- Display a lightning card with details about the record -->
    <div class="Record Details"> 
        <lightning:card iconName="standard:account" title="{!v.accountRecord.Name}" >
            <div class="slds-p-horizontal--small">
                <p class="slds-text-heading--small">
                    <lightning:formattedText title="Billing State" value="{!v.accountRecord.BillingState}" /></p>
                <p class="slds-text-heading--small">
                     <lightning:formattedText title="Billing City" value="{!v.accountRecord.BillingCity}" /></p>
            </div>
        </lightning:card>
    </div>
    <br/>

    <!-- Display an editing form -->
    <div class="Record Details">
        <lightning:card iconName="action:edit" title="Edit Account">
            <div class="slds-p-horizontal--small">
                <lightning:input label="Account Name" value="{!v.accountRecord.Name}"/>
                <br/>
                <lightning:button label="Save Account" variant="brand" onclick="{!c.handleSaveRecord}" />
            </div>
        </lightning:card>
    </div>


    <aura:if isTrue="{!not(empty(v.recordSaveError))}">
		<br />

        Error: <ui:outputText value="{!v.recordSaveError}"/>

    </aura:if>
</aura:component>


accEditcontroller.js
({
    handleSaveRecord: function(cmp, event, helper) {
        cmp.find("recordEditor").saveRecord($A.getCallback(function(saveResult) {
            if (saveResult.state === "ERROR") {
                var errMsg = "";
                // saveResult.error is an array of errors, 
                // so collect all errors into one message
                for (var i = 0; i < saveResult.error.length; i++) {
                    errMsg += saveResult.error[i].message + "\n";
                }
                cmp.set("v.recordSaveError", errMsg);
            } else {
                cmp.set("v.recordSaveError", "");
            }
        }));}
})

 
Hi,

I am extremely new at writing apex code and I managed to write a trigger, but I don't quite know how to write a test class for it. My trigger looks like this:

trigger Changestage on Opportunity ( before update) {

    set<ID> oppId = new set<ID>();
    for (Opportunity opp: Trigger.new) {
    if ((opp.StageName == 'Detailed Design') && (trigger.oldMap.get(opp.Id).StageName == 'Concept Design') && (opp.Equipment_Margin__c == null)) {
          opp.addError('Cannot move the stage to Detailed Design if the Equipment Margin is empty');
        }  
    }
}

Any help is much appreciated.

Thank you!

Alexandra
hi Please

how to done pagination with custome object with controller ??

 same formate how to slove please support me «12345» ?


thanks
Hi everyone, I am working through the Reports and Dashboard Superbadge. The Lightning Hobbies by Contact keeps failing the challenge. I am also getting for the error message “does not have correct report type or correct columns (most likely).’’ I would really appreciate it if someone can tell me what is wrong with the report. So far I have:
checked the custom report type,
checked the hobby category Outdoor Activities filter is locked,
tried all the different combinations of names for the hobby name column,
checked Account name and Account value are sorted and grouped correctly. I have had to group the Account name and Account value columns because it is not possible to summarize them.
recreated the report, recreated the report type and even emptied the recycle bin to ensure the correct unique name was being used.
Report picture

Kind regards Sarah Colville-Los

 
 
I have two lists which are populated by REST Response.First list is List<Business> Abc and second is List<Sales> xyz.
1)List<Busiess> Abc have below parameters
-AccountNumber
-BusinessStatus
-BusinessDescrib
2)List<Sales> xyz have below parameters:
-AccountNumber
-salesStatus
-salesDesc

AccountNumber is a common value in Both list.

I want to display the single table with account number and Its repective parameters from both lists (BusinessStatus,BusinessDescrib,salesStatus and salesDesc)
 
Hi,

I have an existing functionality - whenever an attachment is uploaded on child record, it will get automatically inserted on Parent record as well. This works fine.  Now the parent record's attachment has to be deleted whenever a child record's attachment is deleted. Any idea how to accomplish this?

Thanks,
Nish
  • September 30, 2017
  • Like
  • 0
Hello,

I want to add a button to my Product2 object that lets a user upload a photo of the product. I would like the image URL be stored automatically in a field on the Product2 record after uploading. I am guessing that to achieve this, I need to make some kind of visualforce widget for uploading the image, tie that to the action of a button on the object, and then have some kind of workflow rule or apex trigger fire after the image is uploaded and enter its URL into the field. What is the easiest way to do this?
Hello,
I have a button on my page which runs a VF Page with an extension to my controller. It works to press the button and it produces the EchoSign Agreement as directed. However, the page it goes to when I click the button is a blank page. I would like to redirect it to the Id of the record I just created upon pressing the button. Basic outline of code below. So how can I get a void method to redirect to the ID of the record it just created?
public void SendPdf(){
//reference PDF Creator VF Page
pageReference pdfPage = Page.ContactPDF;
pdfPage.getParameters().put('Id',getid);
blob pdfBody;
pdfBody = pdfPage.getContentAsPDF();
          
// Build Echosign agreement record
echosign_dev1__SIGN_Agreement__c agreementRec = new echosign_dev1__SIGN_Agreement__c();
agreementRec.Name = 'Credit Info Release for: ';
//other variables entered here
insert agreementRec;

// insert the pdf as an attachment
attachment pdfFile = new attachment();
pdfFile.isPrivate = false;
pdfFile.body = pdfBody;
pdfFile.parentId = agreementRec.id;
pdfFile.Name = 'Agreement.pdf';
insert pdfFile;
}

 
I'm doing the simple lightning components challenge and have hit this problem in my existing trailhead org and a brand new dev org that I've just created:

Challenge not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: QVWBQHAG