• Nihar A
  • NEWBIE
  • 133 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 20
    Replies

I've tried the code below (removed some items for confidentiality) but I receive the "made it to the query locator" debug message but never receive the "made it to the execute" debug.  I'm calling it by entering

batchGenerateAssets be = new batchGenerateAssets();
database.executeBatch(be);

in Execute Anonymous Window of the Developer Console

 

What am I doing wrong?

global class batchGenerateAssets implements Database.Batchable<sObject>, Database.AllowsCallouts{

 public String query = 'Select Id, PakSize__c, ProductFamily, UsageEndDate, Product2Id  FROM Asset WHERE SerialNumber = \'**Generate**\' ';

global Database.QueryLocator start(Database.BatchableContext BC)
{   
     System.debug('made it to querylocator');

    return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC, List<Asset> assetList) {
System.debug('made it to execute');
      
  ///////////////////////////////////////////////////////////////////////////////
    

      
}   
      global void finish(Database.BatchableContext BC)
      {
      }
}

 
Hi,
I am using Eclipse for Light component development. Initially I developed in dev console and recently started working in Eclipse.For Some of the components that i developed using dev console.I have not created helper and Renderer and CSS file. When I fetched them into my eclipse, only component and controller code has been fetched which is understandable as I only have that code created. Now when I am looking for an option to create a helper/style for that component but could not find an option to do it directly in eclipse. I could only see new lightning component bundle creation option.
One work around might be to go back to dev console, create helper/style and then fetch it to eclipse. I want to know if there is an option to directly create that in eclipse.

Nihar.
Hello, I am trying to update a field on case object based on the user's currency who is creating the case. I am not able to find $User.currency fields  to directly access the value in criteria. I am using another field on case object which is set to user's Id when it is being created and I am using this custom field to access user's currency.

So logic looks like :

if (case.customfield.defaultcurrencyIsoCode == 'USD') then set Case.country = 'USA' and so on..

But Process is throwing error saying ..The flow failed to access the value for myVariable_current.customfield.DefaultCurrencyIsoCode because it hasn't been set or assigned.

But I am assigning custom field to user id while creating the case. I am not sure why this is working. Any help is appreciated.
I want to display a URL on Global Action Page Layout. Is there a way to do that? I tried to use a formula field to generate a URL but I am not able to place it on the layout of the Global action.
I was working on on converting Js buttons in our classic org to lightning compatible using lightnng actions and lightning components. Is it possible to use this lightning custom functionality somehow in classic for those buttons OR should I keep both the lightning actions and classic on-click JS buttons until we make a complete transition to lightning as I think users would be switching to classic and lightning in between when they are working on any stuff that is not available in either classic or lightning.
If something goes wrong in lightning component and I go back to component bundle and mofidy the logic there and save and comeback to browser and refresh the page and execute the component , But the component is sometimes displaying the same old logic. Is it because the Javascript handler code is being cached in browser or any other reason. I am able to look at the new logic in browser after making three or four refreshes.
I am trying to convert a Custom JS button in classic into Lightning action. it is a button on account object. The logic in classic looks something like this:

var a= account.id;
var b = account.type;
var c = account.recordType;

if(a != "" && b == //somevalue && c== somevalue){
//do something;
}
else{
//do something;
}

If I want to convert this logic into lightning whats the best way to do it. As I am using account attributes to decide on the logic that I am going to excute I need access to few account record's details.
Approach I used:

Component Code :

<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" controller="ApexController">
    <aura:handler name="init" value="{!this}" action="{!c.JsHandler}" />
    <aura:attribute name="recordId" type="Id" />
  <aura:attribute name="acc" type="Account"
         default="{ 'sobjectType': 'Account',
                           'Name': '',
                         'Type': '',
                           'RecordType.Name':''     
                       }"/>
</aura:component>

Handler:

var action =  component.get("c.getData");
        action.setParams({"accountId": component.get("v.recordId")});
        action.setCallback(this, function(response){
            component.set("v.acc",response.getReturnValue());
            var acctType = component.get("v.acc.Type");
            var RecordType = component.get("v.acc.RecordType.Name");
            var acctName = component.get("v.acc.Name");
            var acctId = component.get("v.acc.Id");
          // same logic as in the above classic JS button and decide what to do.

Apex Controller:
public class GetNeededData {
    @AuraEnabled
    public static account getData(Id accountId){
        return [select Name,Type,RecordType.name from Account where Id = :accountId];
    }
}

I have a few questions in this implementation:
1) Is this the best possible way to do this or Are there any patterns that I am missing?
2) To access the data returned from the controller, should I declare an account attribute "acc" in the component and use it in the handler to access data from controller OR can I directly create an account record in handler and assign the returned result to it. If yes , how.
3) And if I want to create a case in one of the if else logic , Should I first create a Case attribute in the component and then assign different values in handler and then push that data to controller and Insert the data in controller or Can I use Ajax Toolkit's sobject.connection.create to push the data directly to SF insetad of using a controller.

Thanks in Advance.

Nihar.

 


 
I am trying to write a queueable apex class by implementing the Queueable interface. Everything works fine but the system debug statements that I write in the execute() method are not showing up in the logs. Is it the way that execute method works or is it the problem with logging levels. i do not think its the problem with logging level because I am able to see other system debug statements which are not in execute method in the logs once execution is finished.

Thank you for you time.
Can we use system.runAs() with the user record that is created but not inserted into database?

For Example :

User A = new User();
A.name = XXXXX
A.Profile = XXXXX
A.role = XXXXX
A.email = XXXX

System.runAs(A){

//some code

}

In the above exaample I am creating a new Dummy test user A , providing some field values but not inserting it in the database.

If we can use it what are the pros and cons of using it this way.

Thank you.
Hi,
I am using Eclipse for Light component development. Initially I developed in dev console and recently started working in Eclipse.For Some of the components that i developed using dev console.I have not created helper and Renderer and CSS file. When I fetched them into my eclipse, only component and controller code has been fetched which is understandable as I only have that code created. Now when I am looking for an option to create a helper/style for that component but could not find an option to do it directly in eclipse. I could only see new lightning component bundle creation option.
One work around might be to go back to dev console, create helper/style and then fetch it to eclipse. I want to know if there is an option to directly create that in eclipse.

Nihar.
If something goes wrong in lightning component and I go back to component bundle and mofidy the logic there and save and comeback to browser and refresh the page and execute the component , But the component is sometimes displaying the same old logic. Is it because the Javascript handler code is being cached in browser or any other reason. I am able to look at the new logic in browser after making three or four refreshes.

I've tried the code below (removed some items for confidentiality) but I receive the "made it to the query locator" debug message but never receive the "made it to the execute" debug.  I'm calling it by entering

batchGenerateAssets be = new batchGenerateAssets();
database.executeBatch(be);

in Execute Anonymous Window of the Developer Console

 

What am I doing wrong?

global class batchGenerateAssets implements Database.Batchable<sObject>, Database.AllowsCallouts{

 public String query = 'Select Id, PakSize__c, ProductFamily, UsageEndDate, Product2Id  FROM Asset WHERE SerialNumber = \'**Generate**\' ';

global Database.QueryLocator start(Database.BatchableContext BC)
{   
     System.debug('made it to querylocator');

    return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC, List<Asset> assetList) {
System.debug('made it to execute');
      
  ///////////////////////////////////////////////////////////////////////////////
    

      
}   
      global void finish(Database.BatchableContext BC)
      {
      }
}

 
Hello,

I have this scenario where I have a child object called 'reserve__c'  for an 'opportunity' as a parent.

when a new opportunity is created ,I want to make sure user creates reserve__c record as well.
Can someone please help me with the solution! 
sObject customObj = [SELECT field1, field2, (SELECT field3, field4 FROM customDetailsObject__r) FROM customObj WHERE Id = :currentCustomObj t.Id]; 

// Referencing field3 => error : A non foreign key field cannot be referenced in a path expression
System.debug(customObj .customDetailsObject__r.field3);

// Get customDetailsObject.Id and parent Id (customObj.Id)
System.debug(customObj .customDetailsObject__r);
I'm trying to get field of child custom object from custom parent object but I'm sure what I'm doing wrong when trying accessing it. I have used the "Child Relationship Name".

The singular and plural name are the same (no 's' added or whatsoever) so I don't know if that's the issue. 

 
Hi,
 i have created recently Developer edition org, while creating workflow i can not see task creation in work flow action ?

previouly it is there,  any idea ?

thank
Royal
  • March 11, 2017
  • Like
  • 0
Hello, I am trying to update a field on case object based on the user's currency who is creating the case. I am not able to find $User.currency fields  to directly access the value in criteria. I am using another field on case object which is set to user's Id when it is being created and I am using this custom field to access user's currency.

So logic looks like :

if (case.customfield.defaultcurrencyIsoCode == 'USD') then set Case.country = 'USA' and so on..

But Process is throwing error saying ..The flow failed to access the value for myVariable_current.customfield.DefaultCurrencyIsoCode because it hasn't been set or assigned.

But I am assigning custom field to user id while creating the case. I am not sure why this is working. Any help is appreciated.
I have built an extensive Opportunity trigger that creates a new Location_Detail__c record, which is the child to Locaiton Master.
I am having a difficult time building a test class to deploy it. I can only achive 10% coverage, and only seem to able to cover the if statement.
Does anyone have any ideas how to test the remainder? I have attahced a section of the trigger and my test class.

Thanks, you guys are the best! 
 
trigger locStatusOpp on Opportunity (after update, after insert) { 
    
    List<Location_Detail__c> loctoInsert  = new List<Location_Detail__c>();
    
        for (Opportunity opp : Trigger.new) {
         if (opp.StageName == 'Closed Won' && opp.Location__c == 'Auburn Hills MI' && opp.Category__c != null && opp.Type_of_Charge__c == 'Subscription '){
            Location_Master__c locAuburnHillsMI = [SELECT Id FROM Location_Master__c
                                            WHERE Name = 'Auburn Hills MI' LIMIT 1];
            Location_Detail__c locNewAuburnHillsMI     =  new Location_Detail__c(
            Name                          =  opp.Name,
            Location__c                   =  opp.Location__c,
            On_List__c					  =  1,
            Location_Master__c			  =  locAuburnHillsMI.Id,
            Vendor_Type__c                =  opp.Category__c);  
                if(opp.Location__c == 'Auburn Hills MI'){
                loctoInsert.add(locNewAuburnHillsMI);
                    }
         }
 
@istest
private class locStatusOppTEST {
    
    @isTest static void locStatusOppTEST(){
        
       	List<Location_Detail__c> loctoInsert  = new List<Location_Detail__c>();
        
        Opportunity opp = new Opportunity();
            opp.Name 			  = 'Test';
            opp.AccountId   	  =  opp.Id;
            opp.Type_of_Charge__c = 'Subscription';
            opp.Category__c       = 'Bartender';
            opp.Location__c	      = 'Des Moines IA';
            opp.StageName		  = 'Closed Won';
            opp.CloseDate		  = date.newInstance(2017, 2, 20);
            insert opp;
    
    }
}

 
If something goes wrong in lightning component and I go back to component bundle and mofidy the logic there and save and comeback to browser and refresh the page and execute the component , But the component is sometimes displaying the same old logic. Is it because the Javascript handler code is being cached in browser or any other reason. I am able to look at the new logic in browser after making three or four refreshes.
I am trying to convert a Custom JS button in classic into Lightning action. it is a button on account object. The logic in classic looks something like this:

var a= account.id;
var b = account.type;
var c = account.recordType;

if(a != "" && b == //somevalue && c== somevalue){
//do something;
}
else{
//do something;
}

If I want to convert this logic into lightning whats the best way to do it. As I am using account attributes to decide on the logic that I am going to excute I need access to few account record's details.
Approach I used:

Component Code :

<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" controller="ApexController">
    <aura:handler name="init" value="{!this}" action="{!c.JsHandler}" />
    <aura:attribute name="recordId" type="Id" />
  <aura:attribute name="acc" type="Account"
         default="{ 'sobjectType': 'Account',
                           'Name': '',
                         'Type': '',
                           'RecordType.Name':''     
                       }"/>
</aura:component>

Handler:

var action =  component.get("c.getData");
        action.setParams({"accountId": component.get("v.recordId")});
        action.setCallback(this, function(response){
            component.set("v.acc",response.getReturnValue());
            var acctType = component.get("v.acc.Type");
            var RecordType = component.get("v.acc.RecordType.Name");
            var acctName = component.get("v.acc.Name");
            var acctId = component.get("v.acc.Id");
          // same logic as in the above classic JS button and decide what to do.

Apex Controller:
public class GetNeededData {
    @AuraEnabled
    public static account getData(Id accountId){
        return [select Name,Type,RecordType.name from Account where Id = :accountId];
    }
}

I have a few questions in this implementation:
1) Is this the best possible way to do this or Are there any patterns that I am missing?
2) To access the data returned from the controller, should I declare an account attribute "acc" in the component and use it in the handler to access data from controller OR can I directly create an account record in handler and assign the returned result to it. If yes , how.
3) And if I want to create a case in one of the if else logic , Should I first create a Case attribute in the component and then assign different values in handler and then push that data to controller and Insert the data in controller or Can I use Ajax Toolkit's sobject.connection.create to push the data directly to SF insetad of using a controller.

Thanks in Advance.

Nihar.

 


 
Can we use system.runAs() with the user record that is created but not inserted into database?

For Example :

User A = new User();
A.name = XXXXX
A.Profile = XXXXX
A.role = XXXXX
A.email = XXXX

System.runAs(A){

//some code

}

In the above exaample I am creating a new Dummy test user A , providing some field values but not inserting it in the database.

If we can use it what are the pros and cons of using it this way.

Thank you.