• Parth Thakkar
  • NEWBIE
  • 35 Points
  • Member since 2015

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 2
    Questions
  • 9
    Replies
Hello Experts!

I am trying to create a test apex class, which saves just fine, however when I attempt to actually run the test for the test class, i get the following error: Error Message System.QueryException: unexpected token: WHERE
Stack Trace Class.MyClosedIssuesTest.testMyClosedIssues: line 23, column 1

Here is my code, can anyone tell me what I may have done incorrectly, as google searching has yielded no results. 

@IsTest(SeeAllData=true)
public class MyClosedIssuesTest {

    static testMethod void testMyClosedIssues() {
        SObjectType objToken = Schema.getGlobalDescribe().get('Backlog__c');
        DescribeSObjectResult objDef = objToken.getDescribe();
        Map<String, SObjectField> fields = objDef.fields.getMap();
        Set<String> fieldSet = fields.keySet();

        String query = 'SELECT ';
        Integer counter = 0;
        for(String s : fieldSet) {
            counter++;
            SObjectField fieldToken = fields.get(s);
            DescribeFieldResult selectedField = fieldToken.getDescribe();
            query = query + selectedField.getName();
            if(counter < fieldSet.size()) {
                query = query + ', ';
            }
        }
        
        String query1 = query + 'FROM Backlog__c WHERE createdbyid = \'' + userinfo.getuserid() + '\'order by createddate desc';
        Backlog__c testIssue = Database.query(query1);
        
        
        
        testIssue.Parent__c = 'a3W180000008ddj';
        testIssue.Scheduled_Release__c = 'a3l18000000085c';
        testIssue.Environment__c = 'Production';
        testIssue.Summary__c = 'Add New Items To Account and Contact';
        testIssue.Description__c = 'Test';
        update testIssue;
        Backlog__c result = [Select ID,Description__c FROM Backlog__c WHERE Id = :testIssue.Id];
        
    }
}

Thank you in advance for any help you may be able to provide

Shawn
I am using Custom email for approval request using Apex Class. 

How to build External URL in apex? 

ApprovalRequest.External_URL
Trying to replicate this https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_flows_lightningruntime.htm
 but getting error here is my code. 

App:
<aura:application access="global"  extends="ltng:outApp" implements="ltng:allowGuestAccess">
	<aura:dependency resource="lightning:flow"/>
</aura:application>
VF Page: 
<apex:page >
   <html>
      <head>
         <apex:includeLightning />
      </head>
      <body class="slds-scope">
          
         <div id="flowContainer"/>
         <script>
            var statusChange = function (event) {
               if(event.getParam("status") === "FINISHED") {
                  // Control what happens when the interview finishes
 
                  var outputVariables = event.getParam("outputVariables");
                  var key;
                  for(key in outputVariables) {
                     if(outputVariables[key].name === "myOutput") {
                        // Do something with an output variable
                     }
                  }
               }
            };
            $Lightning.use("c:FlowVFPage", function() {
               // Create the flow component and set the onstatuschange attribute
               $Lightning.createComponent("lightning:flow", {"onstatuschange":statusChange},
                  "flowContainer",
                  function (component) {
                     // Set the input variables
                      
                     
                     // Start an interview in the flowContainer div, and 
                     // initializes the input variables.
                     component.startFlow("New_Customer", inputVariables);
                  }
               );
            });
         </script>
      </body>
   </html>
</apex:page>

How to solve this error? thanks in Advance. 


 
Hi,

I am fairly new to working with Aura Components but have managed to build a component which shows all non-completed tasks on the user Home Page.
I have added a checkbox next to each Task and this is where I am stuck. I would like the Task Status to be updatet to 'Completed' when the checkbox i marked (true). How to accomplish this?

Any help is appreciated, thanks!

ApexController:
public class ALTaskController {
    @AuraEnabled
    public static List<Task> getTasks(){
        List<Task> taskList = [SELECT Id,Subject,Description,OwnerId,ActivityDate,WhoId,Priority,Status,Type FROM Task WHERE ActivityDate <= NEXT_N_DAYS:3 AND Status != 'Completed' ORDER BY ActivityDate ASC];
        return taskList;
    }
}
Component:
<aura:component controller="ALTaskController" implements="flexipage:availableForAllPageTypes,force:appHostable" access="global">
	<aura:attribute name="tasks" type="List" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />


        <lightning:card class="accountCard" variant="Narrow" iconName="standard:task" footer="Card Footer">
            <aura:set attribute="title">
                Mine opgaver
            </aura:set>
            <aura:set attribute="actions">
                <lightning:buttonIcon iconName="utility:down" variant="border-filled" alternativeText="Show More"/>
            </aura:set>
            <aura:set attribute="body">
                <p class="slds-p-horizontal_small">
                    <aura:iteration items="{!v.tasks}" var="task"> <!-- Use the Apex model and controller to fetch server side data -->
                    <lightning:tile label="{!task.Subject}" href="{!'/one/one.app?#/sObject/'+ task.Id + '/view'}">
                        <aura:set attribute="media">
							<lightning:input type="checkbox" name="input1" title="Fuldført"/>
                            <!--<lightning:icon iconName="standard:task"/>-->
                        </aura:set>
                        <div class="demo-only demo-only--sizing slds-grid slds-wrap">
                            <div class="slds-size_3-of-12">
                                <div class=""><p class="slds-truncate">Forfaldsdato:</p></div>
                            </div>
                            <div class="slds-size_9-of-12">
                                <div class=""><p class="slds-truncate"><lightning:formattedDateTime value="{!task.ActivityDate}" year="numeric" month="numeric" day="numeric"/></p></div>
                            </div>
                            <div class="slds-size_3-of-12">
                                <div class=""><p class="slds-truncate">Status:</p></div>
                            </div>
                            <div class="slds-size_9-of-12">
                                <div class=""><p class="slds-truncate">{!task.Status}</p></div>
                            </div>
                            <div class="slds-size_3-of-12">
                                <div class=""><p class="slds-truncate">Kommentar:</p></div>
                            </div>
                            <div class="slds-size_9-of-12">
                                <div class="" title="{!task.Description}"><p class="slds-truncate">{!task.Description}</p></div>
                            </div>
                        </div>
                    </lightning:tile>
                    </aura:iteration>
                </p>
            </aura:set>
            <aura:set attribute="footer">
            </aura:set>
        </lightning:card>
</aura:component>
Controller:
({
	doInit: function(component, event, helper) {
        // Fetch the task list from the Apex controller
        helper.getTaskLists(component);
    }
})
Helper:
({
	// Fetch the accounts from the Apex controller
    getTaskLists: function(component) {
        var action = component.get('c.getTasks');
        // Set up the callback
        var self = this;
        action.setCallback(this, function(actionResult) {
            component.set('v.tasks', actionResult.getReturnValue());
        });
        $A.enqueueAction(action);
    }
})
Trying to replicate this https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_flows_lightningruntime.htm
 but getting error here is my code. 

App:
<aura:application access="global"  extends="ltng:outApp" implements="ltng:allowGuestAccess">
	<aura:dependency resource="lightning:flow"/>
</aura:application>
VF Page: 
<apex:page >
   <html>
      <head>
         <apex:includeLightning />
      </head>
      <body class="slds-scope">
          
         <div id="flowContainer"/>
         <script>
            var statusChange = function (event) {
               if(event.getParam("status") === "FINISHED") {
                  // Control what happens when the interview finishes
 
                  var outputVariables = event.getParam("outputVariables");
                  var key;
                  for(key in outputVariables) {
                     if(outputVariables[key].name === "myOutput") {
                        // Do something with an output variable
                     }
                  }
               }
            };
            $Lightning.use("c:FlowVFPage", function() {
               // Create the flow component and set the onstatuschange attribute
               $Lightning.createComponent("lightning:flow", {"onstatuschange":statusChange},
                  "flowContainer",
                  function (component) {
                     // Set the input variables
                      
                     
                     // Start an interview in the flowContainer div, and 
                     // initializes the input variables.
                     component.startFlow("New_Customer", inputVariables);
                  }
               );
            });
         </script>
      </body>
   </html>
</apex:page>

How to solve this error? thanks in Advance. 


 
Hello Experts!

I am trying to create a test apex class, which saves just fine, however when I attempt to actually run the test for the test class, i get the following error: Error Message System.QueryException: unexpected token: WHERE
Stack Trace Class.MyClosedIssuesTest.testMyClosedIssues: line 23, column 1

Here is my code, can anyone tell me what I may have done incorrectly, as google searching has yielded no results. 

@IsTest(SeeAllData=true)
public class MyClosedIssuesTest {

    static testMethod void testMyClosedIssues() {
        SObjectType objToken = Schema.getGlobalDescribe().get('Backlog__c');
        DescribeSObjectResult objDef = objToken.getDescribe();
        Map<String, SObjectField> fields = objDef.fields.getMap();
        Set<String> fieldSet = fields.keySet();

        String query = 'SELECT ';
        Integer counter = 0;
        for(String s : fieldSet) {
            counter++;
            SObjectField fieldToken = fields.get(s);
            DescribeFieldResult selectedField = fieldToken.getDescribe();
            query = query + selectedField.getName();
            if(counter < fieldSet.size()) {
                query = query + ', ';
            }
        }
        
        String query1 = query + 'FROM Backlog__c WHERE createdbyid = \'' + userinfo.getuserid() + '\'order by createddate desc';
        Backlog__c testIssue = Database.query(query1);
        
        
        
        testIssue.Parent__c = 'a3W180000008ddj';
        testIssue.Scheduled_Release__c = 'a3l18000000085c';
        testIssue.Environment__c = 'Production';
        testIssue.Summary__c = 'Add New Items To Account and Contact';
        testIssue.Description__c = 'Test';
        update testIssue;
        Backlog__c result = [Select ID,Description__c FROM Backlog__c WHERE Id = :testIssue.Id];
        
    }
}

Thank you in advance for any help you may be able to provide

Shawn
public class fileAttach{
Public Attachment myfile{get;set;}
Public String VMfileName{get;set;}
public String ContactIds{get;set;}
public Contact con{get;set;}
public List<Contact> contacts{get;set;}
Public Attachment getmyfile()
    {
        myfile = new Attachment();
        return myfile;
    }
    
    public fileAttach(ApexPages.StandardController controller) {
       ContactIds= ApexPages.currentPage().getParameters().get('array');
      }
 Public Pagereference Savedoc()
    {
      if(ContactIds!= null || ContactIds!= ''){
         List<String> strConIds= ContactIds.split(',');
            for(Id conId:strConIds){
                Attachment a = new Attachment(parentId =conId,name=myfile.name, body = myfile.body);
                insert a;
                 }
}
 return null;
 }   
}
test class...

@isTest(seealldata=true)
public class testfileattach
{
    static testmethod void testfileattach()
    {
        Contact con=new Contact(LastName='Test Name',payroll__c='rakhul');
        insert con;
        Pagereference ref=page.conatactsaved;
        ref.getParameters().put('id', String.valueOf(con.id));//for page referenc
        Test.setcurrentpage(ref);
        ApexPages.StandardController cont = new ApexPages.StandardController(con);
        fileAttach fill=new fileAttach(cont);
        fill.VMfileName='';
        Attachment att=new Attachment();
        att=fill.getmyfile();
        fill.Savedoc();
    }
  }
test class passed with 50 %code coverage
but whenever i was calling pagerefence  savedoc method getting error that System.NullPointerException: Attempt to de-reference a null object
stack trace
Class.fileAttach.Savedoc: line 24, column 1
Class.testfileattach.testfileattach: line 16, column 1
Hi folks,
          Can anyone give me the sample bootsrap datepicker in visualforce page/
Thanks in advance
Karthick

Work REMOTELY for this fast growing Silver Level Partner!!  In this position, the developer will work closely with Consultants/Architects and clients to determine project requirements and design solutions using native Salesforce, Apex and VisualForce.  The right person will have experience with Communities, knowledge of relational databases and modeling, knowledge of object oriented methodologies and approaches and have some .Net experience. - See more at: http://jobs.tech2resources.com/Salesforce-Developer-Jobs-in-Remote-Position-DC/3223198#sthash.mGUymZ2j.dpuf