• DanSad
  • NEWBIE
  • 25 Points
  • Member since 2012

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

I have a list of Names in excel that I need to search for the Opportunity ID.  I have got it to work for just one name, but I'm unsure of how I take this massive excel list of names and retrieve the Opportunity ID?  Any Ideas I could try?

 

>>> query_result = svc.query("select id, Name from opportunity where Name like 'Customer A Tire Place%'")
>>> for rec in query_result[sf.records:]:
...     print str(rec[2]) + " : " + str(rec[3])
...
00xx000000XXXJbXXX : Customer A Tire Place
>>>

 

Thanks for your time,


DK

I want to write a batch to take all the values in a given fieldset, and overwrite them with another fieldset.

 

In our account object, we have added many fields: several fields for each month of the current, next, and previous year.

Examples: JAN_CURYEAR_Volume__c, FEB_CURYEAR_Volume__c, MAR_PREVYEAR_Revenue__c etc. 

 

Fieldsets are used to group by year. Examples: CURYEAR_Revenue, PREVYEAR_Revenue, CURYEAR_Volume etc.

A given index will point to the same month in any fieldset. 

 

So I'd like to be able to overwrite PREVYEAR_Volume with CURYEAR_Volume, and so on. 

But I'm not sure how to write the iterator, or if I should use an iterator at all!

What's the best way?

 

Thanks board members!

DS

 

 

  • November 19, 2013
  • Like
  • 0

I have VF pageblock that I put in my Account Detail page. The block has some input fields in it. 

Now every time I load up an account detail page, it jumps down to the block and puts the cursor in the first inputfield. 

How do I avoid this?

 

 EDIT:

Nevermind, found this:

I wrote a class with a few functions that return account IDs based on a custom field.

 

public class ComplaintOperations{
    public static Id getaid(string client_id){
        //Try to find Account with matching client_id, with or without leading 0s. return Account ID if found, otherwise return null
        Account[] a = [find :client_id in all fields returning Account(Id,client_id__c where Client_Id__c like :client_id) limit 1][0];
        if (a.size() !=0){    
        	return a[0].id;}
        else{string othercid = '00'+client_id;
        	Account[] a2 = [find :othercid in all fields returning Account(Id,client_id__c where Client_Id__c like :othercid) limit 1][0];
            if(a2.size()!= 0){return a2[0].id;}
             else{return null;}
            }
    }
             
             
    public static Boolean isclientid(string client_id){
        if(getaid(client_id) == null){return false;}
        else{return true;}
    }
}

 It works just fine when i run it from the console:

system.debug(complaintoperations.getaid('0012345'));

 yields the correct ID.

 

But my unit tests:

@isTest
public class testComplaintOperations{
    
    static testMethod void testGetAid(){
        string cid = '999999999';
        Account a = New Account(Name='Daniel Sadster',client_id__c = cid,status__c = 'Active');
        insert a;
        system.assert(a != null);
        system.assertequals(a.id,ComplaintOperations.getaid(cid));
        System.assertequals(null,ComplaintOperations.getaid('123'));
    }
    static testMEthod void testisclient(){
    	string cid = '999999999';
        Account a = New Account(Name='Daniel Sadster',client_id__c = cid,status__c = 'Active');
        insert a;
        system.assertequals(Complaintoperations.isclientid(cid),true);
        system.assertequals(Complaintoperations.isclientid('pooppypants'),false);
    }
}

 Keep failing!

Apparently because the "find" statements in my class yield nothing.

Any ideas?

 

Hi,

I'm using apex:repeat along with fieldsets to create rows of input fields for my users.

I want to create a button at the beginning of each row that will take the value in the first input field, and fill it into the rest of the input fields of that row. 

I tried a jQuery function that I called on the ID of the repeated elements. Here's the jQuery function:

<script type="text/javascript">
           function fillAll(fields,v){
           $("[id$=fields]").val(v)
           } 
</script>

 Here's one of the rows, with command button. The row is ID'd as PrevYear_SiOW:

<td>Size of Wallet <apex:commandButton value="Fill all " onclick="fillAll('PrevYear_SiOW',10)"/>
</td>
<apex:repeat value="{!$ObjectType.Account.FieldSets.PrevYear_SioW_set}" var="c">
<td><apex:inputField id="PrevYear_SiOW" value="{!Account[c]}" style="font-size:small; width:55px"/></td>
</apex:repeat></tr>

 

 

 

 

 

 

  • April 11, 2013
  • Like
  • 0

I have a list of Names in excel that I need to search for the Opportunity ID.  I have got it to work for just one name, but I'm unsure of how I take this massive excel list of names and retrieve the Opportunity ID?  Any Ideas I could try?

 

>>> query_result = svc.query("select id, Name from opportunity where Name like 'Customer A Tire Place%'")
>>> for rec in query_result[sf.records:]:
...     print str(rec[2]) + " : " + str(rec[3])
...
00xx000000XXXJbXXX : Customer A Tire Place
>>>

 

Thanks for your time,


DK

I wrote a class with a few functions that return account IDs based on a custom field.

 

public class ComplaintOperations{
    public static Id getaid(string client_id){
        //Try to find Account with matching client_id, with or without leading 0s. return Account ID if found, otherwise return null
        Account[] a = [find :client_id in all fields returning Account(Id,client_id__c where Client_Id__c like :client_id) limit 1][0];
        if (a.size() !=0){    
        	return a[0].id;}
        else{string othercid = '00'+client_id;
        	Account[] a2 = [find :othercid in all fields returning Account(Id,client_id__c where Client_Id__c like :othercid) limit 1][0];
            if(a2.size()!= 0){return a2[0].id;}
             else{return null;}
            }
    }
             
             
    public static Boolean isclientid(string client_id){
        if(getaid(client_id) == null){return false;}
        else{return true;}
    }
}

 It works just fine when i run it from the console:

system.debug(complaintoperations.getaid('0012345'));

 yields the correct ID.

 

But my unit tests:

@isTest
public class testComplaintOperations{
    
    static testMethod void testGetAid(){
        string cid = '999999999';
        Account a = New Account(Name='Daniel Sadster',client_id__c = cid,status__c = 'Active');
        insert a;
        system.assert(a != null);
        system.assertequals(a.id,ComplaintOperations.getaid(cid));
        System.assertequals(null,ComplaintOperations.getaid('123'));
    }
    static testMEthod void testisclient(){
    	string cid = '999999999';
        Account a = New Account(Name='Daniel Sadster',client_id__c = cid,status__c = 'Active');
        insert a;
        system.assertequals(Complaintoperations.isclientid(cid),true);
        system.assertequals(Complaintoperations.isclientid('pooppypants'),false);
    }
}

 Keep failing!

Apparently because the "find" statements in my class yield nothing.

Any ideas?

 

Hi all,

I am a newbie to Salesforce and have been reading the SalesForce API docs. I am currently reading the Bullk upload API and wanted to i mplement bulk uploading of data via a python script. I have been looking into libraries like Beatbox and salesforce-toolkit. Can bulk upload my data via a python script using the API. If yes can anybody give me some pointers?

 

Thanks.

 

Avinash Prasad

Hi,

 

I've been getting to grips with the Salesforce API via the Salesforce Python Toolkit recently. While I can do most of what I want to be able to do, I'm flummoxed by trying to create records containing lookup relationships. I've read a lot about using foreign keys, and making nested SObjects in Java and so on, but wondered if anyone could give me an example using the Salesforce Python Toolkit specifically.

 

For the purpose of illustration, suppose that I have two custom objects: "Project__c" and "Person__c". The project has a person associated with it using a lookup field "Associate__c" and the Person object is identified by "Ext_ID__c", 

 

This is what I've tried so far:

 

proj = sf.generateObject('Project__c')

pers = sf.generateObject('Person__c')

pers.Ext_ID__c = 'externalID'

proj.Associate__c = pers.Ext_ID__c

result = sf.create(proj)

 

In principle, the person should already exist in the database before the project is submitted. I'm not sure it this makes much of a difference.

 

I think my problem is that pers.Ext_ID__c isn't functioning as an ID, but I don't really understand why, or how to make it behave.

 

Any suggestions would be most welcome.

 

Thank you!