• SFDCmack08180939826349907
  • NEWBIE
  • 30 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 8
    Replies
My goal is to store Apex code in a parent object ex. Account that has code in a long text area field and has a picklist with operation ex Update or Insert. The code will execute in the child code ex. Case and so will the operation.  
 
Account sa=[select id,Code_Text_field__c,operation_picklist__c from Account where id='001i000001zbIZR'];
Object CodeBlock=Code_Text_field__;
Object Operation=operation_picklist__c ;
 

Case c=[select id from Case where AccountId=:sa.id];
system.debug('CESAR@'+c);
CodeBlock;
Operation;

I understand the system is reading this as strings values, so how could I convert the Codeblack variable in Apex code and the Operation variable in DML statement?
I am stuck trying to get the Group query to get the territory name, could someone let me know what I am doing wrong here, I get this error message
'Initial term of field expression must be a concrete SObject: List<AccountShare>'

VF:
 
<apex:page controller="DisplayQueryList"> 
    <apex:pageBlock title="My Content"> 
        <apex:pageBlockTable value="{!Recs}" var="Record"> 
            <apex:column > 
                <apex:facet name="header">User</apex:facet> 
                  <apex:outputText value="{!Record.Id}"/> 
                    </apex:column>
<apex:column > 
                <apex:facet name="header">UserID or Group</apex:facet> 
                  <apex:outputText value="{!Record.UserOrGroupId}"/> 
                    </apex:column>

          
            
          
          
                        
        </apex:pageBlockTable> 
    </apex:pageBlock> 
</apex:page>



Apex:
 
public with sharing class TestDisplayQueryList{ 
public List<AccountShare> Recs {get; set;} 
public DisplayQueryList(){ 

Rec = [Select Id, UserOrGroupId from AccountShare where (RowCause ='Territory' OR RowCause = 'TerritoryManual' )And AccountId='001i0000009Rmz5' ];    
Group grp =[select id from Group where id IN :Records.id ];
   


} 
}

 
The code appears to be working from the debug logs and resetting the password internally by clicking on the view button in Visualforce. I am not sure what I am missing:

* An apex page controller that exposes the site forgot password functionality
 */
Global class ForgotPasswordController {
    Global String username {get; set;}   
      
     
             
   Global ForgotPasswordController() {}
    
    Global PageReference forgotPassword() {
        User usr = [select Id from User where username=:username];
        system.debug(usr);
        boolean success = Site.forgotPassword(username);
        PageReference pr = Page.ForgotPasswordConfirm;
        pr.setRedirect(true);
       
       
        if (success) {
            system.resetPassword(usr.Id,True);         
            return pr;
        }
        return null;
    }
    
     Global static testMethod void testForgotPasswordController() {
        // Instantiate a new controller with all parameters in the page
        ForgotPasswordController controller = new ForgotPasswordController();
        controller.username = 'test@salesforce.com';        
    
        System.assertEquals(controller.forgotPassword(),null); 
    }
}

When you go to communities and conduct a password reset outside it does not work why?
Exception System.InvalidParameterValueException: Invalid ID.
6:31:23.257 (257944442)|USER_DEBUG|[196]|DEBUG|Deleted Successfulyka1m00000008cObAAI
16:31:23.257 (257949254)|SYSTEM_METHOD_EXIT|[196]|System.debug(ANY)
16:31:23.257 (257961641)|SYSTEM_METHOD_ENTRY|[197]|KM_DisplayArticleDataviewController.__sfdc_selectedKnowledgeId()
16:31:23.257 (257989994)|SYSTEM_METHOD_EXIT|[197]|KM_DisplayArticleDataviewController.__sfdc_selectedKnowledgeId()
16:31:23.258 (258004532)|SYSTEM_METHOD_ENTRY|[197]|System.debug(ANY)
16:31:23.258 (258010574)|USER_DEBUG|[197]|DEBUG|Deleted SuccessfulykA1m00000008aKGCAY
16:31:23.258 (258014979)|SYSTEM_METHOD_EXIT|[197]|System.debug(ANY)
16:31:23.258 (258024951)|SYSTEM_METHOD_ENTRY|[199]|KM_DisplayArticleDataviewController.__sfdc_rejectedValidationStatus()
16:31:23.258 (258051279)|SYSTEM_METHOD_EXIT|[199]|KM_DisplayArticleDataviewController.__sfdc_rejectedValidationStatus()
16:31:23.258 (258087213)|SYSTEM_METHOD_ENTRY|[201]|KM_DisplayArticleDataviewController.__sfdc_selectedArchived()
16:31:23.258 (258107462)|SYSTEM_METHOD_EXIT|[201]|KM_DisplayArticleDataviewController.__sfdc_selectedArchived()
16:31:23.258 (258253700)|SYSTEM_METHOD_ENTRY|[202]|KbManagement.PublishingService.publishArticle(String, Boolean)
16:31:23.265 (265281002)|SYSTEM_METHOD_EXIT|[202]|KbManagement.PublishingService.publishArticle(String, Boolean)
16:31:23.265 (265344845)|SYSTEM_METHOD_ENTRY|[215]|String.valueOf(Object)
16:31:23.265 (265387566)|SYSTEM_METHOD_EXIT|[215]|String.valueOf(Object)
16:31:23.265 (265403723)|SYSTEM_METHOD_ENTRY|[215]|System.debug(ANY)
16:31:23.265 (265409661)|USER_DEBUG|[215]|DEBUG|Exception System.InvalidParameterValueException: Invalid ID.
  I get an unexpected token: 'execute' in line 3 any know what I am doing wrong?

Public class KBDelete{
    
    public static void PageReference execute(){
           Id id = ApexPages.currentPage().getParameters().get('id');
        String articleId = 'id';
           
     KbManagement.PublishingService.archiveOnlineArticle(articleId, null);

  
}
           
   
                                                             }

Visualforce 
<apex:commandButton value="Delete" action="{!execute}"></apex:outputLink></apex:commandButton>
Code:
public class CaseOwnerOaeController {
 
    // Constructor - this only really matters if the autoRun function doesn't work right
    private final Case o;
    public CaseOwnerOaeController(ApexPages.StandardController stdController) {
        this.o = (Case)stdController.getRecord();
    }
     
    // Code we will invoke on page load.
    public PageReference autoRun() {
 
        String theId = ApexPages.currentPage().getParameters().get('id');
 
        if (theId == null) {
            // Display the Visualforce page's content if no Id is passed over
            return null;
        }
 
        for (Case o:[select id,ownerId from Case where id =:theId]) {
              o.ownerId='00Gd0000001hJXH';
             update o;
                 
        }
 
        // Redirect the user back to the original page
        PageReference pageRef = new PageReference('/' + theId);
        pageRef.setRedirect(true);
        return pageRef;
 
    }
 
}

Test class:

public class CaseOwnerOaeControllerTest {
    private static void testMethod test (){
    case testObj=new mycase();
     // set values in testObj appropriately
     CaseOwnerOaeController controller = new MyController();
     controller.o=testObj;
     controller.autoRun();
     System.assertNotEquals(null, testObj.id);

    }

}
 I am stuck on how to doe this the normal way of using {!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} does not work for me becuase I need this button to work with  users who do not have access to API.
My goal is to store Apex code in a parent object ex. Account that has code in a long text area field and has a picklist with operation ex Update or Insert. The code will execute in the child code ex. Case and so will the operation.  
 
Account sa=[select id,Code_Text_field__c,operation_picklist__c from Account where id='001i000001zbIZR'];
Object CodeBlock=Code_Text_field__;
Object Operation=operation_picklist__c ;
 

Case c=[select id from Case where AccountId=:sa.id];
system.debug('CESAR@'+c);
CodeBlock;
Operation;

I understand the system is reading this as strings values, so how could I convert the Codeblack variable in Apex code and the Operation variable in DML statement?
I am stuck trying to get the Group query to get the territory name, could someone let me know what I am doing wrong here, I get this error message
'Initial term of field expression must be a concrete SObject: List<AccountShare>'

VF:
 
<apex:page controller="DisplayQueryList"> 
    <apex:pageBlock title="My Content"> 
        <apex:pageBlockTable value="{!Recs}" var="Record"> 
            <apex:column > 
                <apex:facet name="header">User</apex:facet> 
                  <apex:outputText value="{!Record.Id}"/> 
                    </apex:column>
<apex:column > 
                <apex:facet name="header">UserID or Group</apex:facet> 
                  <apex:outputText value="{!Record.UserOrGroupId}"/> 
                    </apex:column>

          
            
          
          
                        
        </apex:pageBlockTable> 
    </apex:pageBlock> 
</apex:page>



Apex:
 
public with sharing class TestDisplayQueryList{ 
public List<AccountShare> Recs {get; set;} 
public DisplayQueryList(){ 

Rec = [Select Id, UserOrGroupId from AccountShare where (RowCause ='Territory' OR RowCause = 'TerritoryManual' )And AccountId='001i0000009Rmz5' ];    
Group grp =[select id from Group where id IN :Records.id ];
   


} 
}

 
The code appears to be working from the debug logs and resetting the password internally by clicking on the view button in Visualforce. I am not sure what I am missing:

* An apex page controller that exposes the site forgot password functionality
 */
Global class ForgotPasswordController {
    Global String username {get; set;}   
      
     
             
   Global ForgotPasswordController() {}
    
    Global PageReference forgotPassword() {
        User usr = [select Id from User where username=:username];
        system.debug(usr);
        boolean success = Site.forgotPassword(username);
        PageReference pr = Page.ForgotPasswordConfirm;
        pr.setRedirect(true);
       
       
        if (success) {
            system.resetPassword(usr.Id,True);         
            return pr;
        }
        return null;
    }
    
     Global static testMethod void testForgotPasswordController() {
        // Instantiate a new controller with all parameters in the page
        ForgotPasswordController controller = new ForgotPasswordController();
        controller.username = 'test@salesforce.com';        
    
        System.assertEquals(controller.forgotPassword(),null); 
    }
}

When you go to communities and conduct a password reset outside it does not work why?
I need finalizing this apex class to reset a password for the user and log the current user out of salesforce.  Here is my code any ideas I get this error message.
public class resetyourpassword {
  String user=userinfo.getuserId();
  system.resetPassword(user,true);
   PageReference demoPage = new pagereferenct('/secur/logout.jsp');
    demoPage.setRedirect(true);
}



I get an error unexpected token: ',' in line 3  where  system.resetPassword(user,true); id located
Code:
public class CaseOwnerOaeController {
 
    // Constructor - this only really matters if the autoRun function doesn't work right
    private final Case o;
    public CaseOwnerOaeController(ApexPages.StandardController stdController) {
        this.o = (Case)stdController.getRecord();
    }
     
    // Code we will invoke on page load.
    public PageReference autoRun() {
 
        String theId = ApexPages.currentPage().getParameters().get('id');
 
        if (theId == null) {
            // Display the Visualforce page's content if no Id is passed over
            return null;
        }
 
        for (Case o:[select id,ownerId from Case where id =:theId]) {
              o.ownerId='00Gd0000001hJXH';
             update o;
                 
        }
 
        // Redirect the user back to the original page
        PageReference pageRef = new PageReference('/' + theId);
        pageRef.setRedirect(true);
        return pageRef;
 
    }
 
}

Test class:

public class CaseOwnerOaeControllerTest {
    private static void testMethod test (){
    case testObj=new mycase();
     // set values in testObj appropriately
     CaseOwnerOaeController controller = new MyController();
     controller.o=testObj;
     controller.autoRun();
     System.assertNotEquals(null, testObj.id);

    }

}