• ADG
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 5
    Replies
Need an urgent help. I have created a standard object named Engagement and created a Calendar from the object to see only the Engagement items in it; but I want to create a Calendar from that object for all users and set it as the default one, so that any user can just login and go to the calendar to see the Calendar items on the Engagement object.
Any Idea on how to do so?
  • February 19, 2017
  • Like
  • 0
I have put a Custom Button on a page which triggers an Approval Process, so I want to remove the Submit for Approval button from the Approval History section.

I found several posts suggesting using of a jquery to remove the button, but those did not work.
https://developer.salesforce.com/forums/?id=906F00000009F8IIAU
https://developer.salesforce.com/forums/?id=906F00000008pZMIAY

I have put the following jQuery code in a VF Page and added it to the Sidebar of the Home Page Component, but the Submit for Approval button did not get removed:
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
      $j = jQuery.noConflict();
      $j(document).ready(function(){   
        $j("input[name='piSubmit']").hide();
      });
    </script>

If someone knows what I am missing, please let me know.
Also any other alternative idea to achieve this is very much welcome.
  • October 27, 2016
  • Like
  • 0
I have created an Approval Process and am launching it from an Apex code behind a custom button which is working fine, but the problem is that I am not able to set the Approver from the Apex code (instead it always takes the Approver that is set in the Approval Process.)

Here is what I tried:
    Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
    req.setComments('Submitted for approval. Please approve. Source:ApexClass');
    req.setObjectId(dcr.Id);
    req.setNextApproverIds(new Id[] {'0057E000001dn5T'}); // This is the id of a user
    Approval.ProcessResult result = Approval.process(req);

This submits the record for approval, but sends it to the Approver that is set in the Approval Process, and not to the user with id '0057E000001dn5T' that is set in the code

How can I make the code work? Any help would be appreciated.
Also any other alternative idea to achieve this is very much welcome.
  • October 27, 2016
  • Like
  • 0
I have a SOQL query which works fine:
SELECT Id, Name, (SELECT Id,Name FROM Contacts)
                    FROM Account
                    WHERE Name = 'Apollo'

But the following queries, which have been similarly formed as the above, do not run:
SELECT Id, Candidate_Name__c, (SELECT Id,Assessment__c FROM Review__c)
                         FROM Job_Application__c
                         WHERE Candidate_Name__c = 'Jamie Sandras'
Error: "Didn't understand relationship 'Review__c' in FROM part of query call...."
 
SELECT Id, Candidate_Name__c, (SELECT Id,Assessment__c FROM Review__r)
                         FROM Job_Application__c
                         WHERE Candidate_Name__c = 'Jamie Sandras'
Error: "Didn't understand relationship 'Review__r' in FROM part of query call...."

where Review__c is child object of Job_Application__c


So I have 2 questions:

1. Is it a limitation that such queries (with sub-queries to child object) work only for standard objects and not for custom objects?

2. In the first query, why does the sub-query uses the object name "Contacts" and not "Contact" which is the actual object name?
SELECT Id, Name, (SELECT Id,Name FROM Contacts) FROM Account ....
  • December 30, 2016
  • Like
  • 0
I have the following trigger:
trigger HelloWorldTrigger on Book__c (before insert) {
    Book__c[] books = Trigger.new;
    MyHelloWorld.applyDiscount(books);
}
which calls the function in the follwoing class:
public class MyHelloWorld {
    public static void applyDiscount(Book__c[] books) {
        for (Book__c b: books) {
            b.Price__c *= 0.9;
        }
    }
}
but when I am running a test script:
@isTest
private class HelloWorldTestClass {
    static testMethod void validateHelloWorld() {
        Book__c b = new Book__c(Name='Behind the Cloud', Price__c=100);
        System.debug('Price before inserting new book: ' + b.Price__c);
        // Insert book
        insert b;
        // Retrieve the new book
        b = [SELECT Price__c FROM Book__c WHERE Id =:b.Id];
        System.debug('Price after trigger fired: ' + b.Price__c);
        // Test that the trigger correctly updated the price
        System.assertEquals(90, b.Price__c);
    }
}
its giving me a 0% code coverage
User-added image

Can anyone please help me with this?
  • December 10, 2015
  • Like
  • 0
Need an urgent help. I have created a standard object named Engagement and created a Calendar from the object to see only the Engagement items in it; but I want to create a Calendar from that object for all users and set it as the default one, so that any user can just login and go to the calendar to see the Calendar items on the Engagement object.
Any Idea on how to do so?
  • February 19, 2017
  • Like
  • 0
I have put a Custom Button on a page which triggers an Approval Process, so I want to remove the Submit for Approval button from the Approval History section.

I found several posts suggesting using of a jquery to remove the button, but those did not work.
https://developer.salesforce.com/forums/?id=906F00000009F8IIAU
https://developer.salesforce.com/forums/?id=906F00000008pZMIAY

I have put the following jQuery code in a VF Page and added it to the Sidebar of the Home Page Component, but the Submit for Approval button did not get removed:
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
      $j = jQuery.noConflict();
      $j(document).ready(function(){   
        $j("input[name='piSubmit']").hide();
      });
    </script>

If someone knows what I am missing, please let me know.
Also any other alternative idea to achieve this is very much welcome.
  • October 27, 2016
  • Like
  • 0
I have created an Approval Process and am launching it from an Apex code behind a custom button which is working fine, but the problem is that I am not able to set the Approver from the Apex code (instead it always takes the Approver that is set in the Approval Process.)

Here is what I tried:
    Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
    req.setComments('Submitted for approval. Please approve. Source:ApexClass');
    req.setObjectId(dcr.Id);
    req.setNextApproverIds(new Id[] {'0057E000001dn5T'}); // This is the id of a user
    Approval.ProcessResult result = Approval.process(req);

This submits the record for approval, but sends it to the Approver that is set in the Approval Process, and not to the user with id '0057E000001dn5T' that is set in the code

How can I make the code work? Any help would be appreciated.
Also any other alternative idea to achieve this is very much welcome.
  • October 27, 2016
  • Like
  • 0
I have a SOQL query which works fine:
SELECT Id, Name, (SELECT Id,Name FROM Contacts)
                    FROM Account
                    WHERE Name = 'Apollo'

But the following queries, which have been similarly formed as the above, do not run:
SELECT Id, Candidate_Name__c, (SELECT Id,Assessment__c FROM Review__c)
                         FROM Job_Application__c
                         WHERE Candidate_Name__c = 'Jamie Sandras'
Error: "Didn't understand relationship 'Review__c' in FROM part of query call...."
 
SELECT Id, Candidate_Name__c, (SELECT Id,Assessment__c FROM Review__r)
                         FROM Job_Application__c
                         WHERE Candidate_Name__c = 'Jamie Sandras'
Error: "Didn't understand relationship 'Review__r' in FROM part of query call...."

where Review__c is child object of Job_Application__c


So I have 2 questions:

1. Is it a limitation that such queries (with sub-queries to child object) work only for standard objects and not for custom objects?

2. In the first query, why does the sub-query uses the object name "Contacts" and not "Contact" which is the actual object name?
SELECT Id, Name, (SELECT Id,Name FROM Contacts) FROM Account ....
  • December 30, 2016
  • Like
  • 0
I have the following trigger:
trigger HelloWorldTrigger on Book__c (before insert) {
    Book__c[] books = Trigger.new;
    MyHelloWorld.applyDiscount(books);
}
which calls the function in the follwoing class:
public class MyHelloWorld {
    public static void applyDiscount(Book__c[] books) {
        for (Book__c b: books) {
            b.Price__c *= 0.9;
        }
    }
}
but when I am running a test script:
@isTest
private class HelloWorldTestClass {
    static testMethod void validateHelloWorld() {
        Book__c b = new Book__c(Name='Behind the Cloud', Price__c=100);
        System.debug('Price before inserting new book: ' + b.Price__c);
        // Insert book
        insert b;
        // Retrieve the new book
        b = [SELECT Price__c FROM Book__c WHERE Id =:b.Id];
        System.debug('Price after trigger fired: ' + b.Price__c);
        // Test that the trigger correctly updated the price
        System.assertEquals(90, b.Price__c);
    }
}
its giving me a 0% code coverage
User-added image

Can anyone please help me with this?
  • December 10, 2015
  • Like
  • 0