• Vincent Albiser
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Hi,

We have a few custom fields say A, B and C, all these are a lookup to User fields. The goal is to share the Account record with any User populated in the custom fields A, B or C. 
How can we create a sharing rule for this? Can we have public group with user names ? 
Please suggest me on this.

Thanks.
I have the following apex method and this method i am going to use in custom detail button but the problem is it will give me an error as following :

User-added image


Apex Method :
 
public pagereference StartSync(){
    try{
        opp = [Select Id, AccountId from Opportunity where id =: Quote.OpportunityId];

        opp.SyncedQuoteId = Quote.Id;
        opp.Tax__c = Quote.Tax__c;
        opp.Freight_Amount__c = Quote.Freight__c;

        update opp;
        pagereference pg = new Pagereference('/apex/QuoteDetail?id='+this.Quote.Id);
        pg.setRedirect(true);
        return pg;
    }Catch(Exception e){
        return null;
    }
}

Javascript :
 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 
sforce.apex.execute("QuoteGroupCreateController","StartSync",{});



Can anybody tell what i am doing wrong in this ?
So I am writing a class to pull out community login data from the user object to populate a custom object which will be used to create reports for customers, since community users are unable to access the user object.

Here's what I have so far.  Thinking this should work but I'm getting an error when populating the data into the custom object.
 
global class CommunityLoginHistory implements Schedulable {
    
    // This method queries the LoginHistory Object for Community User logins in the past 15 minutes and populates the CommunityLoginHistory custom object.
 
    global void execute(SchedulableContext ctx) {
        DateTime d = Datetime.now().addMinutes(-15);
        List<User> UserLoginHistory = [SELECT Id,
                                              name, 
                                              LastLoginDate, 
                                              profile.name, 
                                              userrole.name, 
                                              account.name 
                                            FROM User 
                                            WHERE profile.name LIKE '%Customer Community Plus%' 
                                            AND isactive = true 
                                            AND LastLoginDate > :d ];
                                            
        if ( !UserLoginHistory.isEmpty()) {
            List<CommunityLoginHistory__c> clh = new List<CommunityLoginHistory__c>();
            for (User ulh : UserLoginHistory) {
                clh.add (new CommunityLoginHistory__c ( UserID__c           =   Id,
                                                        UserName__c         =   name,
                                                        LastLoginDate__c    =   LastLoginDate,
                                                        UserProfile__c      =   profile.name,
                                                        UserRole__c         =   userrole.name,
                                                        UserAccount__c      =   account.name
                ));
            }
            insert clh;
        }
    }
}
In the for loop, when trying to populate the record with the data that was pulled from the SOQL query, the Developer Console is giving me the following errors.

Line 21 - Variable does not exist: Id - Illegal assignment from Schema.SObjectField to String
Line 22 - Variable does not exist: name - Illegal assignment from Schema.SObjectField to String
Line 23 - Variable does not exist: LastLoginDate - Illegal assignment from Schema.SObjectField to String

I'm at a loss for why that is the case when the console doesn't complain about the other variables.  Hoping someone can help.