• Swathi Miryala
  • 9 Points
  • Member since 2015

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
  • 2
I have custom button that calls custom VF page. I need to validate before submitting to VIsualforce page. The condition is if user id is in opportunity team then should redirect to page otherwise should display insufficient rights message.
I have following code

sforce.connection.sessionId = "{!$Api.Session_ID}";

var user = sforce.connection.getUserInfo();

if("{!Opportunity.Id}" != "") { 

if("{!OpportunityTeamMember.User.Id}" == user.userId) { 
  window.top.location = "/apex/LibraryRedirect?Id={!Opportunity.Id}"; 
} else { 
  alert("You do not have permissions to upload file"); 

However this - OpportunityTeamMember.User.Id doesnot work.

Can you please help me. 


I am getting following error on the production. We haven't changed anything on production.

"__MISSING LABEL__ PropertyFile - val EnvironmentCreation not found in section Setup_NavBETA"

This occurs on left side bar in set up. This is between "Installed packages" and "Appexchange Marketplace".
It appears a link and onclick of it takes to "Setup Dev hub" page
I see this error all of sudden in just production. All the sandboxes look normal.
Please help.

Has anyone build folder hierarchy for content libraries using APIs.  I am able to build the content folder but cannot view it on UI. when i query on it, i can see the that it got created. What is the correct approach? Basically I want to build Folders and Sub Folders in Libraries.

ContentFolder c = new ContentFolder();
c.Name = 'New Project Folder1';
insert c; 
Please guide me.



I'm trying to build a query to returns a list of Opportunity IDs where the Opportunity Owner doesn't match the Account Owner. 

I've tried this : 
SELECT Id FROM Opportunity WHERE OwnerId != Opportunity.Account.OwnerId. 
But it doesn't work.

Any Idea ? 

Hello everyone I could use some help on the using future Methods trailhead. Please keep in mind I am not an Apex coder at all but I am trying to learn as much as I can.

Here is the Task

Create an Apex class with a method using the @future annotation that accepts a List of Account IDs and updates a custom field on the Account object with the number of contacts associated to the Account. Write unit tests that achieve 100% code coverage for the class.
Create a field on the Account object called 'Number_of_Contacts__c' of type Number. This field will hold the total number of Contacts for the Account.
Create an Apex class called 'AccountProcessor' that contains a 'countContacts' method that accepts a List of Account IDs. This method must use the @future annotation.
For each Account ID passed to the method, count the number of Contact records associated to it and update the 'Number_of_Contacts__c' field with this value.
Create an Apex test class called 'AccountProcessorTest'.
The unit tests must cover all lines of code included in the AccountProcessor class, resulting in 100% code coverage.
Run your test class at least once (via 'Run All' tests the Developer Console) before attempting to verify this challenge.

I have written an Apex class and a Test class but I think I am doing them both Wrong: because when I try to check the challenge i Get this error

Challenge Not yet complete... here's what's wrong: 
The 'AccountProcessorTest' test class doesn't appear to be calling the 'AccountProcessor.countContacts' method between Test.startTest() and Test.stopTest().

When I run the Test class I get this error :

System.QueryException: List has no rows for assignment to SObject

Here is the CLASS:
public class AccountProcessor {

  public static void someFutureMethod(List<id> scope) {

   Account[] updates = new Account[] {};
        for (AggregateResult ar : [
                select AccountId a, count(Id) c
                from Contact
                where AccountId in :scope
                group by AccountId
                ]) {
            updates.add(new Account(
                    Id = (Id) ar.get('a'),
                    Number_of_Contacts__c = (Decimal) ar.get('c')
        update updates;


Here is the Test Class:
public class AccountProcessorTest {
  public static testmethod void TestAccountProcessorTest() {
     Account a = new Account();
        a.Name = 'Test Account';
        Insert a;
      Contact cont = New Contact();
      cont.FirstName ='Bob';
      cont.LastName ='Masters';
      cont.AccountId = a.Id;
      Insert cont;

    Test.stopTest() ;
     Contact ACC = [select AccountId from Contact where id = :a.id LIMIT 1];

        System.assert(Cont.AccountId != null);
        System.assertequals(cont.id, ACC.AccountId);


I have used alot or diffrent google searches to get me this far. But I have not Idea if Im even remotly close to the right answer or not.