• Bindhyachal Kumar Singh
  • NEWBIE
  • 155 Points
  • Member since 2012
  • Certified Sr. Salesforce Developer
  • Astrea IT Services


  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 78
    Replies
global class CreateRootCause implements Database.Batchable<sObject>,
Schedulable {

public String Query;
global CreateRootCause(){

String ProjectQuery = 'Select Id,Name,Dev_Lead_User__c from Project__c where Overall_Project_Status__c NOT IN (\'Not Started\',\'On hold\') AND Project_TQL_Phase__c !=\'1. Kick-off\' AND Project_State__c IN(\'Active\')';

        
        
        this.Query=ProjectQuery;         
    }
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(Query);
    }
    
    global void execute(Database.BatchableContext BC, List<SObject> scope)
    {
        List<Project__c> ProjectList =(Project__c[]) scope; 
                               
    
    for(project__c prj: ProjectList)
    { 

        List<Task__c> Lsttask=new List<Task__c>();
        Lsttask=[Select id,project__c from Task__c where project__c=: prj.Id];  
        List<Root_Cause__c> lstRC=new List<Root_Cause__c>();
    for(Task__c thistask: Lsttask)
        {
            
            Root_Cause__c RCDel= new Root_Cause__c();
            RCDel.TaskName__c=thistask.Id;
            RCDel.Date__c=System.Today();  
            RCDel.Final__c=true;
            RCDel.Project_Name__c=thistask.Project__c;
            RCDel.Launch_Date_Delay__c=0; 
            RCDel.Dev_Lead__c=prj.Dev_Lead_User__c;     
            lstRC.add(RCDel);     
            //lsttask.add(thistask);
        }    
  
     insert lstRC;
    }
 
}
global void finish(Database.BatchableContext BC){
}
  

                //Execute batch class with default constructor from schedular
    global void execute(SchedulableContext sc) {
        
        
       try {
    
         database.executeBatch(new CreateRootCause());

        }
        catch (Exception e) {
            System.debug('There are no jobs currently scheduled. ' + e.getMessage()); 
        } 
   }   
    
}

How to write test class for the above code..please help me on this...

Hi guys,

 

I developed an Visualforce Page, which shows all Objects that are available. Now I want to find all Instances of one Particular Object. 

 

I tried some stuff like this, but can't verify if it works, cause i have no idea how i could get a String with the Name out of the SObject.

Do I need a wrapperclass for showing the Results in a table?

 

String queryString = 'SELECT Id, Name, FROM '+ paramFromVF; // paramFromVF is the name of the Object
List<sObject> L = Database.query(queryString);

 

Anyway, I think this is quite a beginner question, but as I am a beginner this is tough for me at the moment.

Thanks a lot for your help.

  • March 07, 2013
  • Like
  • 0

Hi,

 

We are not able to use the deploy function at our company because of a trigger on the production server that has 0% code coverage. I am an administrator and have never had to write test code before. Have read everything I can about how to do it, but I don't understand the logic. Have tried to write it in every way I could possibly think of. Could you please try to help me write a test class for this?

 

I REALLY appreciate all help I can get!

 

This is the trigger:

trigger subscription on subscription_update__c (after insert) {
 Map<Id,Subscription_Update__c> subsToKill = new Map<Id,Subscription_Update__c>();
 List<Contact> contactsToProcess = new List<Contact>();
 for (Subscription_Update__c sub : Trigger.new) {
  Contact contact = new Contact (    
   id=sub.contact__c,
   Email = sub.email_address__c,
   HasOptedOutOfEmail = sub.Unsubscribe_Me__c,
   Subscription_Type__c = sub.Subscription_Type__c );
   contactsToProcess.add(contact);
  subsToKill.put(sub.id,sub);
 }
 if(contactsToProcess.size()>0){
  try {
   update contactsToProcess;  
   //delete subsToKill.values();
        } catch (exception e) { 
         system.debug(e.getMessage()); 
        }  
 } 
}

 

 

i have two objects inventory and order ....when a record is created in order object for an item then automatically the field quantity avialable in inventory is to be updated with( quantity available  minus  order quantity)

 and i have a hint also (select Inventory record where id=Inventory look up field’s API name)............please help m,e for this trigeer

  • February 28, 2013
  • Like
  • 0
I want get a list of all the users who are part of public group of the currently logged in user. In documentations, i have read that  able to pick these values from group and group member objects.

A record exists for every User or Group who is a direct member of a public group whose Type field is set to Regular. User records that are indirect members of Regular public groups are not listed as group members. A User can be an indirect member of a group if he or she is in a UserRole above the direct group member in the hierarchy, or if he or she is a member of a group that is included as a subgroup in that group.

Can we get all users of a group using group id? Please help me ASAP it's urgent.

Hi All,

 

Can we create Pagelayout using MetadataAPI in salesforce using java. If yes then please give me some sample of code.

 

i have tried following code but it does not work.

LayoutItem li = new LayoutItem();
           	li.setField(uniqueobjectName+"."+uniqueField);
           	li.setHeight(100);
           	li.setWidth("30");           	
           	
           	LayoutColumn lc = new LayoutColumn();
           	lc.setLayoutItems(new LayoutItem[] {li});
        	
           	LayoutSection ls = new LayoutSection();
            ls.setCustomLabel(true);
            ls.setLabel("ABC");
            ls.setDetailHeading(true);
            ls.setLayoutColumns(new LayoutColumn[] {lc});
           	
            Layout lay = new Layout();
           	lay.setEmailDefault(true);
           	lay.setFullName("Report_Object_2__c-Bindhyachal");
           	lay.setLayoutSections(new LayoutSection[] {ls});
         	
           	AsyncResult[] asyncResults1 = metadataConnection.create(new Layout[] {lay});

 

Hi All, I have created a lookup field on my custom object to contact and it is used on visual force page.

Also i have used custom lookup page.

In salesforce org it works fine and display lookup value.

But when i use this page in sites then lookup value doesnot show for those contact which have no account.

If contact have account then it shown. I have already give permission to site users.  

 

Please help me. it is urgent......

Hi

without overriding page, can we hide fields from standard page.
I have a custom page which is added to a section in page layout and need to hide those fields which is shown in custom page from standard page because it appears twice.......

 

It's urgent ....

Please reply........If any way

Hi, 

I could really use some guidence on a current problem I'm faced. Any help would be much appreciated.

I have 2 custom objects with a master detail relationship: parent__c and child__c. 

A Parent__c record  contains information for 4 payments. Chilld__c will be the recipt for each individual payment. 

What I want is for a user to be able to press a button on the parent and create 4 new child records. Each child record will be a recipt for one of the 4 payments.

Can anyone tell me how this can be achieved?

So far I've seen similar examples using Apex, Flows, Custom Controllers, VF pages and more. All of them are fine, I just don't know which would be most appropriate. 

Thanks in advance. 
  • August 19, 2014
  • Like
  • 0
Hi,
           I have one frequency picklist field.I this picklist field values are Weekly,Monthly by day,Monthly by date and custom.When i select Weekly picklist value page rendered as Sunday,Monday.......Saturday checkboxes will be displayed.When i select Monthly by day picklist value page rendered as two picklists one is 1st,2nd,3rd,4th and last ,second picklist as Sunday,Monday.......Saturday  will be displayed.When i select Monthly by date picklist value page rendered as picklist as  1st,2nd,3rd,4th........31st and  last   will be displayed.When i select Custom value in picklist page rendered as  DayOfMonth(Textbox),Month:(Textbox),DayOfWeek:(Textbox),Year:(Textbox) .I gave Job name ,Startdate,Enddate and PreferredStartTime field as Hours(12AM,1AM....11PM),Minuts(00,01,02....59) and seconds(00,01,02....59).

NOTE:UI I designed how to perform backend operation based on my UI.

How to add Frequency as CRON Expresson Dynamically From visualforce page?

please help me..............

Can anyone tell me what is wrong with the format of this query?:

List<KnowledgeArticleVersion> kavs = new List<KnowledgeArticleVersion>([SELECT Id, title, UrlName, Summary FROM KnowledgeArticleVersion WHERE PublishStatus = 'online' AND Language = \''+ String.escapeSingleQuotes(language) +'\' AND KnowledgeArticleId IN :statIds]);

Thank you!
Hey.

I would like to get a lookup(relationship) field from an Account to all related Opportunities. I know I can access the Account field via formula field from the Opportunity, but then only get it as text value, where I would like to have it as lookup(relationship) type on the Opportunity as well.
Example: Have the Account Owner on all Opportunities. (not really a necessaty, only an example to understand what I would like)

Is there a how to what steps to follow on how to achieve this?

Thanks for the help in advance.
I want get a list of all the users who are part of public group of the currently logged in user. In documentations, i have read that  able to pick these values from group and group member objects.

A record exists for every User or Group who is a direct member of a public group whose Type field is set to Regular. User records that are indirect members of Regular public groups are not listed as group members. A User can be an indirect member of a group if he or she is in a UserRole above the direct group member in the hierarchy, or if he or she is a member of a group that is included as a subgroup in that group.

Can we get all users of a group using group id? Please help me ASAP it's urgent.

Hi,

 

i'm trying to code an client app to update cases.

 I use the update() call to update a custom field. But when i run my application, i have this error : 

 

"ERROR updating record: Unable to create/update fields: CaseNumber"

 

However i don't set the case number in my case. Is it possible to update cases with the update() call ?

This my code :

 

private static void updateCases() {
   
System.out.println("Querying for the cases...");
   
try {
      
// query for the cases      
QueryResult queryResults = connection.query("SELECT Id, CaseNumber " +
      "FROM Case WHERE RT_id__c = '4622'");
     if (queryResults.getSize() > 0) {
     //Define records
     Case[] records = new Case[queryResults.getSize()];
     
     for (int i=0;i<queryResults.getRecords().length;i++) {
     // cast the SObject to a strongly-typed Case
     Case c = (Case)queryResults.getRecords()[i];
     System.out.println("Id: " + c.getId() + " - CaseNumber: "+c.getCaseNumber());
         
     System.out.println("Update cases...");
         
     //update case
     c.setFramework_Found_in_txt__c("ixE-4.18.0");
     records[i] = c;
     }
         
     SaveResult[] saveResults = connection.update(records);
         // check the returned results for any errors
      for (int i=0; i<saveResults.length; i++) {
      if (saveResults[i].isSuccess()) {
      System.out.println(i+". Successfully updated record - Id: " + saveResults[i].getId());
      } else {
      Error[] errors = saveResults[i].getErrors();
      for (int j=0; j<errors.length; j++) {
      System.out.println("ERROR updating record: " + errors[j].getMessage());
      }
      }    
      }
       
     }    
 
     
} catch (Exception e) {
     e.printStackTrace();
}   
 
 

Hi,

 

Is calling a batch class from a trigger best practice?

 

Thanks in Advance

  • April 11, 2013
  • Like
  • 0

i want a prev and next button on a vf page, but the next button and pre would not go to another page. It would just get the next or previous record in the list to display. any suggestions or code with a similiar functionaloilty that i could get ideas from. thank you. I am using a controller extension. for my vf page. thank you.

Hi,

 

I am trying to re-render two pageblocks. The first pageblock displays a list of all Accounts and the second pageblock adds the User to add a new Account. The first pageblock re-renders with no issues. however, the second pageblock is not re-rendering. The value stays in the inputfield. Here is my code. Please help.

 

<apex:page standardController="Account" extensions="AllMyAccts">
    <apex:form >         
        <apex:pageBlock id="AcctListBlock"> 
            <apex:pageBlockTable value="{!Accounts}" var="a" columns="2">
                <apex:column value="{!a.Name}">
                </apex:column>
                <apex:column value="{!a.AnnualRevenue}"></apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
        
        <apex:pageBlock id="newAcctBlock"> 
        	<apex:pageblocktable var="newacct" value="{!newAcctList}">
        		<apex:column >
        			<apex:inputField value="{!newacct.name}"></apex:inputField>
        		</apex:column>
        	</apex:pageblocktable>
        	
        </apex:pageBlock>
    	<apex:commandbutton value="New Account" action="{!newAccount}" reRender="AcctListBlock, newAcctBlock"/>
    </apex:form>
</apex:page>

 

Thank you in advance.

I have a trigger which I want to disable (it generates data for one field and the import I am doing doesn't need that data generated)

 

If the trigger is active I can deploy it.  If the trigger is inactive I can't deploy it.

 

WHAT THE HELL IS THIS ABOUT?

 

I have another trigger which I can deploy when it is inactive.

I want to display Owner (standard field) in the enhanced list view of one of my Object, in Step 3 of Enhanced List Edit View, I did not found Owner field, instead of that I found Owner Alias, Owner First Name, Owner Last Name.

 

But there is no use for me with those extra fields, I need to show "Owner" in the list view. How can I achieve this ? Plz any one suggest me.

 

Thanks,

Haripriya

Hi Folks,

 

I'm trying to generate the enterprise wsdl as outlined here: http://wiki.developerforce.com/page/Introduction_to_the_Force.com_Web_Services_Connector

 

However, installed on my machine I have java version "1.7.0_11", so I run: 

 

java -classpath wsc-22-jdk-1.7.jar com.sforce.ws.tools.wsdlc enterprise.wsdl enterprise.jar

 

and this gives me the following error:

 

javac: target release 1.6 conflicts with default source release 1.7.

 

So I downgraded to JDK 1.6 and now I get:

 

Unsupported major.minor version 51.0

 

Can please help me to solve this issue.

 

Thanks

Adam