• Noam.dgani
  • NEWBIE
  • 385 Points
  • Member since 2012

  • Chatter
    Feed
  • 15
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 114
    Replies

I'm wondering if I can upload a set of numbers in a different software (other than salesforce) into a salesforce auto number field without the upload doc numbers being changed?

 

Will the excel numbers I place in the salesforce auto-number field stay the same?  Or change based upon the auto-field function?

 

Thanks!

Few questions:

I have a class with 'State' and 'Number'. The combination should be unique, and should be the Name field for the table. I'm hitting some road blocks that I suspect are built-in limitations of SF:

 

  1. Is there a way to make the Name Field a formula? If there is, I haven't found it.
  2. Is there a way to require the Name Field to be unique?
  3. Is there a way to make any Formula Field unique?

One work-around would be using auto-increment for the Name, but this will show up on Lookup Fields, and that's a deal killer. Any suggestions?

Another would be a Trigger that sets the Name before the district is saved and checks for uniqueness. This seems a lot of work for what should be something easy, but I could do it.

 

Is there an elegant approach. What have people tried?

Hello,

 

I have a validation rule right now that requires you to select a task type besides the default when creating a new task.  I recently ran into a problem when our marketing automation tool tries to make a task in salesforce.  On the marketing automation forum for creating a task it does not have the option of selecting a task type so it is set to default which does not comply with my validation rule.  I wanted to know if I could write a trigger that would be able to set the task type before insert when you change the priority to something else besides the default so it will comply with the validation rule.  Thanks.

  • December 03, 2012
  • Like
  • 0

In This below trigger i am trying to update a standard field with the value from custom formula field . ANd the custom formula field looks at campaign date and if campaign date is today  then formula evaluates to ' In progress' and if date is in the past the n 'completed'' and if in date is in future then 'planned'.

 

And my formula works perfect and my trigger works perfect except in one scenario if i have my date as tommorw formula field evaluate to planned and my trigger copies the same value to the standard field and when i log back tommorw and go to the campaign formula field changes automatically to in progess because date is today but my trigger does not copy the value unless i edit the Opportunity .

 

trigger CampaignDelete on Campaign (before delete,before insert,before update) 
{
  //  for (Campaign cg: trigger.old)
    
      //  if(cg.Status == 'In Progress')
        
        //    {
        //    cg.addError('Cannot delete Campaigns with this status');
           
      //     }
     Set<Id> ids = new Set<Id>(); 
     
     list<Campaign> clist = [SELECT Id, Status, Campaign_Status__c FROM Campaign Where Id IN : ids];   
         
         for(Campaign cg : trigger.new){
        cg.Status = cg.Campaign_Status__c ; 
    }
    insert clist;

}

 

And one more question can i use before delete and before update logics in the same trigger ?

 

Thanks

Akhil

  • November 09, 2012
  • Like
  • 0

Hi i have trigger on custom object relationship__c which is having a lookup to contacts.

 

What this trigger does is it checks if an user is having a relationship with the contcat already and if it then it throws an error , it is doing it by checking the Owner field which is automatically populated by default with the created by user.

 

problem with that is no one else can create a relationship for others because dupes are checked by owner field so instead of the owner field i need to pull the id of the person in the name filed and check it . how can i do that  any ideas?

 

trigger CheckDupContactRelationShip on Relationship__c (before insert, before update) {

List<Id> contactIds = new List<Id>();
List<Id> ownerIds = new List<Id>();
List<Relationship__c> duplicateContactRels = null;
Map<String,Integer> mapOfDuplicateValues = new Map<String,Integer>();
Integer k = 0;

/*Looping through batch of new records and adding the contactIds and
OwnerIds to individual lists */

for(Relationship__c cr : Trigger.New)
{
contactIds.add(cr.Contact__c);
ownerIds.add(cr.OwnerId);
}

/*Retrieving all the records into a list where the id matches the id
of records that are being inserted or updated*/

duplicateContactRels = [Select id,Contact__c,OwnerId from Relationship__c
where Contact__c in: contactIds and OwnerId in:ownerIds ];

/*If any duplicate records exist adding those to a map to display the error message
In Trigger Insert/Update */
if(duplicateContactRels != null)
{
for(Relationship__c dcr : duplicateContactRels )
{
mapOfDuplicateValues.put(dcr.Contact__c+ ' ' +dcr.OwnerId, k);
k++;
}
}

if(Trigger.isInsert)
{
for (Integer i = 0; i < Trigger.New.size(); i++)
DisplayErrorForDup(i);
}


else if(Trigger.isUpdate)
{
for (Integer i = 0; i < Trigger.New.size(); i++)
{
if(Trigger.Old[i].Contact__c != Trigger.New[i].Contact__c || Trigger.Old[i].OwnerId != Trigger.New[i].OwnerId )
{
DisplayErrorForDup(i);
}
}
}



public void DisplayErrorForDup(Integer j)
{
if(mapOfDuplicateValues.get(Trigger.New[j].Contact__c+ ' ' +Trigger.New[j].OwnerId)!= null)
Trigger.New[j].addError(Label.ConRel_ErrMsgAlreadyExists);
}
}

 

Thanks 

Akhil

  • November 05, 2012
  • Like
  • 0

Hi,

 

I am getting an error attemptiong to de-reference null object.

 

Can anyone please guide?

 

List<Sub_Proj__c> approvals = [select Id  FROM
                      Sub_Proj__c WHERE ID = :projectDetail.Id];

       if(approvals.isEmpty())
       {
          ApexPages.Message myMsg = new ApexPages.Message(ApexPages.
Severity.ERROR,'Approvals are not present');
                                                    
            ApexPages.addMessage(myMsg);
            return null;
       }
       else
       {
                 if(Projectdeatil.name!=null){
         // do rest work
           }
      
        }
   return returnPage;
    }

Country is pick list field in Account

 

need to populate same country in child object

 

how can we get it

 

I am providing in this manner but not able to get it

Account__r.Country__c

 

error is throwing : Error: Field Country__c is a picklist field. Picklist fields are only supported in certain functions

 

 

  • November 01, 2012
  • Like
  • 0

Hey Everyone - I am new ot the developer community and just getting my feet wet with learning Apex Code.  Could someone steer me in the right direction with the below requested automation?

 

Here is the scenario ---

When checkbox field Custom_Feild_A__c is marked true on Account

Two checkbox fields are updated on the Contact:
Custom_Feild_B__c is marked true
Custom_Feild_C__c is marked true




I have tested this several times but after checking the box on the account the two checkbox fields on the Contact remained unchecked?

  • October 31, 2012
  • Like
  • 0

Here is a field extracted from the REST API endpoint (xx.salesforce.com/services/data/v23.0/sobjects/xx/describe):

 

{
   "length":0,
   "name":"ActivityDate",
   "type":"date",
   "defaultValue":null,
   "label":"Due Date Only",
   "updateable":true,
   "precision":0,
   "scale":0,
   "controllerName":null,
   "byteLength":0,
   "unique":false,
   "calculated":false,
   "nameField":false,
   "sortable":true,
   "filterable":true,
   "nillable":true,
   "caseSensitive":false,
   "inlineHelpText":null,
   "writeRequiresMasterRead":false,
   "externalId":false,
   "idLookup":false,
   "createable":true,
   "soapType":"xsd:date",
   "autoNumber":false,
   "restrictedPicklist":false,
   "namePointing":false,
   "custom":false,
   "defaultedOnCreate":false,
   "deprecatedAndHidden":false,
   "htmlFormatted":false,
   "defaultValueFormula":null,
   "calculatedFormula":null,
   "picklistValues":[

   ],
   "dependentPicklist":false,
   "referenceTo":[

   ],
   "relationshipName":null,
   "relationshipOrder":null,
   "digits":0,
   "groupable":true
}

 

When POSTing an Object using the REST API, we are given an error "Field ActivityDate Required" if we do not include the above field.

 

My question: from the definition above, what is the correct logic to decide if any individual field is required or not when creating new Objects?

  • October 30, 2012
  • Like
  • 0

Dear community,

 

I have a class called by a button into my opportunity who will create an order in our website.

It's working pretty well, but i had to add a check function who will check if the product are in stock.(this function isn't a problem)

 

If one of the opportunity line item is not in stock (by the checking process) i just want to display a message to say "The products below arent in stock : id 1234 id 2569 ....." and don't allow the class to keep working( as a break point).


What is the best way to do it? i didn't understand the add.error method.

 

 

Sincerely,

Antony

Hi all, 

 

I have this rule to stop a convert if the Title field isn't filled out. 

 

AND($RecordType.Name = "Professional", ISBLANKVALUE(Title__c) = TRUE
TEXT(Relationship_with_School__c) <> "Prospective Family"

 

And yet I get this error:

 

Error: Syntax error. Missing ')'

 

Any help would be appreciated!

 

Thank you.

Hi All,

 

Trigger On Task

 

trigger AddTaskActivityToAccountTLA on Task (after insert) {
for (Task task: Trigger.new){
if(task.WhatId!=null){
List<Account> accounts = [select id from Account];
system.debug('Size------------>'+accounts.size());
//List<Account> accounts = [select Name from Account where id =: task.WhatId];
//system.debug('Size------------>'+accounts.size());
if(accounts.size() > 0){
system.debug('accounts[0].id------->'+accounts[0].id);
AccountTLA__c[] accountTLA = [select id from AccountTLA__c where Account__c=: accounts[0].id];
system.debug('accountTLA.size()------->'+accountTLA.size());
if(accountTLA.size()>0){
system.debug('account[0].id------->'+accountTLA[0].id);
Task newtask= new Task(Type=task.Type,OwnerId=task.OwnerId,Subject=task.Subject,ActivityDate=task.ActivityDate,Status=task.Status,Priority=task.Priority,WhatId=accountTLA[0].id);
insert newtask;

}
}
}
}
}

 

I am not able to get account records in the trigger.where i am going wrong....

 

Best ,

Sree

 

 

 

Hi,

 

I am trying to make callout to external service from salesforce , getting exception :

 

System.CalloutException: Web service callout failed: Unexpected element.
Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'

 

When i debug the callout, got following response -

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The requested URL could not be retrieved</H2>
<HR noshade size="1px">
<P>
While trying to retrieve the URL:
<A HREF="http://dev-usmi.genworth.com/ws/GNWFileUtilsES.Services.FileUtilsSvc/GNWFileUtilsES_Services_FileUtilsSvc_Port">http://dev-usmi.genworth.com/ws/GNWFileUtilsES.Services.FileUtilsSvc/GNWFileUtilsES_Services_FileUtilsSvc_Port</A>
<P>
The following error was encountered:
<UL>
<LI>
<STRONG>
Connection to 206.83.178.91 Failed
</STRONG>
</UL>

<P>
The system returned:
<PRE><I>    (113) No route to host</I></PRE>

<P>
The remote host or network may be down.  Please try the request again.
<P>Your cache administrator is <A HREF="mailto:support@salesforce.com">support@salesforce.com</A>. 

<BR clear="all">
<HR noshade size="1px">
<ADDRESS>
Generated Tue, 17 Apr 2012 08:53:17 GMT by proxy-tyo.net.salesforce.com (squid)
</ADDRESS>
</BODY></HTML>

 After analyzed the response am sure that am getting exception because of response am getting as HTML instead of SOAP. Can anyone tell me wat issue may the cause of this response ? and how to resolve it..?

 

Any help would appreciated..

I have a trigger that converts one record into a BUNCH of other records depending on the length of time between two date fields. If the dates are long (like 20 months) and there are 150 of them I hit 3 governor limits (script lines, DML, and query).

 

Several experts have looked over the code with me and the margin for optimization is low, and I'm thinking about the alternatives right now (please feel free to comment as to how much value you see these paths having or if I am leaving out any good ones):

 

1) Have the DB guy only load these records with long dates 20 or 30 at a time. (Q: How long does he need to wait before SF puts them into separate trigger calls?)

 

2) Get rid of the trigger entirely and have a workflow rule that checks a flag on each incoming record to see if it has been processed yet and handle them until the governor limits get close. (Q: How nasty of a hack is this in SF land?)

 

3) Drop SF for heroku, ec2, azure, etc.

Hi

 

can anyone refer me to a good resource that describes which metadata components are exposed via eclipse and more importantly - which are not?

 

Thanks

Hi all

 

I have a sandbox that is integrated with other systems.

When i refresh the sandbox, do i need to give the external systems new WSDLs files or they can just use the same ones they've used so far, or alternatively use the ones from production?

 

Thanks

Hi All

 

My scenario is as follows:

 

I have a REST service that recieves a datetime string with milliseconds.

i need to populate a Datetime field in SF with that value.

 

the problem is that converting a string to datetime ommits the milliseconds.

 

i can manipulate the string to any form that will work - but none seem to.

 

any ideas?

Hi all.i created 2 users(A,B), "A" as system admin and other "B" as Standard User, i created OWD setting as private for lead. so "B" cannot see Lead records.

Requirement: if suppose lead in "A" with email as "S@gmail.com"

WHEN LEAD "B" Tries to create a record with email as "S@gmail.com"(same as already existed). i need to show an popup as "LEAD ALREADY EXISTS. you want to see the lead??"aLSO i need to show the already existed lead reecord("S@gmail.com").this popup and showing the record will happen after click on save.

I think i need create a trigger that shows popup message if email already exists.next i need to create a vf page that shows the already existed record (same email is record). can any one help me how to design.?? because iam not sure how to display the record after save with existing email

How a particular record with already email record will come after click on save , but owd is private. need to show after click on save only after email matches.

 

Thanks

 

I am trying to build a validation rule that will require a date when 1 of 3 fields are updated.  Initially I did

AND(
Asset_Update_Date__c = PRIORVALUE(Asset_Update_Date__c),
OR(
ISCHANGED( Unmanaged_Muni_Assets__c ),
ISCHANGED( A_Share_Assets__c ),
ISCHANGED( C_Share_Assets__c  )))

 

That only works if a date is already in the field. 

 

These fields will initially start off blank as will the date.  What I would like to see happen is when a user updates any of the fields that it requires the Asset_Update_Date field to be updated to the current date.

 

Thanks

  • February 07, 2013
  • Like
  • 0

Hi,

 

I need some help. I have a rating object that holds a rating (rating__c), it is a child of the contact. My trigger updates a filed on the contact with the most recent rating (NPS_Score__c). From there I have a trigger on the contact that looks at all contact score and find the median and updates a field on the account (median_nps_score__c)

 

 

When I try mass updating the rating__c field I get this error:

 

 

UpdateContact: execution of AfterUpdate

 

caused by: System.DmlException: Update failed. First exception on row 0 with id 00330000000W5JJAA0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, NPSScore: execution of AfterUpdate

 

caused by: System.TypeException: Invalid integer: N/

 

Trigger.NPSScore: line 24, column 1: []

 

Trigger.UpdateContact: line 24, column 1

 


Here are my tirggers:

trigger UpdateContact on Rating__c (after insert, after update) {
Set<Id> RatingId = new Set<Id>(); 
for (Rating__c rating : Trigger.new) {
    if(rating.Rating_Type__c != null && rating.Rating_Type__c.equals('Overall')) {
        RatingId.add(rating.Id);
    }
} 
Set<Id> ContactId = new Set<Id>();
for(Rating__c rating1:[Select Contact__c from Rating__c Where Id IN:RatingId ]) {
    ContactId.add(rating1.Contact__c);
}
List<Contact> contactforupdate = new List<Contact>();
for(Contact c:[Select Id, NPS_Rating__c , 
 (Select Rating_Type__c, Rating__c From Product_Ratings__r Where Rating_Type__c = 'Overall' Order by Date__c Desc limit 1 ) 
 from Contact where Id IN:ContactId ]) {
    Rating__c Rating = c.Product_Ratings__r;        
    String RatingValue = Rating.Rating__c;
    System.debug(' ------------ ' + RatingValue);
    //if(c.NPS_Rating__c != null && c.NPS_Rating__c.equals(RatingValue)) {
        c.NPS_Rating__c = RatingValue;
        contactforupdate.add( c );
    //}
}
update contactforupdate;    
}

 

trigger NPSScore on Contact (after insert, after update) {
    //find out Contact list updated or inserted
    Set<Id> ContactIds = new Set<Id>();

    for (Contact con : Trigger.new) {
        if(con.NPS_Rating__c != null) {
            ContactIds.add(con.Id);
        }
    } 



//find out the parent Account list of Contact
Set<Id> AccountIds = new Set<Id>();
for(Contact con:[Select AccountId from Contact Where AccountId != null And Id IN:ContactIds ]) {
    AccountIds.add(con.AccountId);
}

//for each Account, calculate Median value and insert to the Account
List<Account> accountforupdate = new List<Account>();
for(Account acc:[Select Id, (Select NPS_Rating__c from Contacts where NPS_Rating__c != null ) from Account Where Id IN:AccountIds]) {
    List<Integer> contactvalues = new List<Integer>();
    for(Contact con:acc.Contacts) {
        contactvalues.add(Integer.valueOf(con.NPS_Rating__c));
    }

    Integer sizeOfList = contactvalues.size();
    Integer index = sizeOfList - 1;
    Decimal median = 0.0;

    // sort the list first
    contactvalues.sort();
    //Calculate median
    if (Math.mod(sizeOfList, 2) == 0) {
       median = (contactValues[(index-1)/2] + contactValues[(index/2)+1])/2;
    }else{
       median = contactvalues[(index+1)/2];
    }
    system.debug('the median is: '+median);
    acc.Median_NPS_Score__c = median;

    accountforupdate.add(acc);                  
}
update accountforupdate;  
}

 And this is my test

 

@isTest 
private class UpdateContactTestClass {
    static testMethod void validateUpdateContact() {
             
     Contact c = new Contact(MailingCountry='US', FirstName='Testing', LastName='NPSScore', LeadSource='cold call');
       
       // Insert Contact
       insert c;  
     
     Rating__c r = new Rating__c(Contact__c=c.id,Rating_Type__c='overall', Rating__c='8',Date__c=Date.today());
       
       // Insert Rating
       insert r;  
       
    c = [SELECT NPS_Rating__c FROM Contact WHERE Id =:c.Id];
    System.debug('Price after trigger fired: ' + c.NPS_Rating__c);   
     
     // Test that the trigger correctly updated the price
        System.assertEquals('8', c.NPS_Rating__c);  
    }
}

 Any help would be awesome. Thanks!

Hello Everyone, I am facing one problem, I would like to Call WCF RESTFull Service on Account(after update). I would like to create one XML file based on Accound updation. I have written given below Trigger. trigger trgUpdate on Account(after update) { Http http = new Http(); HttpRequest reqL = new HttpRequest(); reqL.setTimeout(60000); reqL.setEndpoint('http://restful.live2.dev.radixweb.net/RestServiceImpl.svc'); reqL.setMethod('GET'); reqL.setHeader('SOAPAction', 'http://restful.live2.dev.radixweb.net/RestServiceImpl.svc'); reqL.setHeader('SetHelloWorld', 'SFDC-Callout/22.0'); reqL.setHeader('Accept','text/xml'); reqL.setHeader('Content-type','text/xml'); reqL.setHeader('charset','UTF-8'); reqL.setBody('This is testing.'); try { HTTPResponse res = hL.send(reqL); System.debug(res.toString()); System.debug('STATUS:'+res.getStatus()); System.debug('STATUS_CODE:'+res.getStatusCode()); } catch(System.CalloutException e) { //Exception handling goes here.... } } // My WCF RESTFULL Service Method [OperationContract] [WebGet(UriTemplate = "/SetHelloWorld", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml)] void SetHelloWorld(); I am waiting for valuable feedback. Thanks.

I'm wondering if I can upload a set of numbers in a different software (other than salesforce) into a salesforce auto number field without the upload doc numbers being changed?

 

Will the excel numbers I place in the salesforce auto-number field stay the same?  Or change based upon the auto-field function?

 

Thanks!

HI I am stuck in a problem.I need code for get object record id with salesforce  by this my problem will soved to redirect on record type... for example URL is 

 

https://cs11.salesforce.com/abc?setupid=CustomObjects

 

I need abc by apex code not by visual force page.Is there any way to fetch this. Please some one rely on this.

  • December 21, 2012
  • Like
  • 0

How can I conditionally control a trigger executing when I am only updating a rollup summary field?

 

Causing me "Too many script statements" error.

  • December 20, 2012
  • Like
  • 0

hi this is the format i am getting response can u parse this format and help me
{
"Success": "true",
"Assessments": [
"AssessmentID": "123456",
"AssessmentName": "Demo Assessment",
"AssessmentType": "Test",
"CostPoints": "1",
"NumberOfQuestions": "35",
"TimeLimit": "2100"
]
}
to retrieve the 6 values only when success is true

i serialized a list ino JSON String.,

 

I am using HTTP Post to send that json to other end.,

 

I need to handle special characters in my JSON string,

 

Please help me.,

  • December 10, 2012
  • Like
  • 0

Hi,

 

I searched a lot of way to improve my code and so far it was working fine.
(around 6-7 classes)

 

I'm currently fightinh with  Strange class class, the validator stop with IF statement or Object creation...it's really crazy...

 

I wrote this post to ask to the community if any one got issues with the code coverage avout :

- IF statement

- Statement inside a loop ( IF inside a For ..)

- Items creation...

 

i found some idea on internet but i just improved my test from 10 to 23 % ...

 

Sincerely

Hi,

 

In below trigger while updation of record i am checking the new expiration date and old expiration date and if they are not equal then i am updating the field Record_Support_Expiration_Date_Sub_Text1__c but what is the problem its not  working

 

trigger UpdateoldExpirationdateonChange on Record_Support__c (Before update) {
try {
      List<Record_Support__c updateList = new List<Record_Support__c>();
         for (Integer i = 0; i < Trigger.new.size(); i++)   { 
         
            if (Trigger.new[i].Expiration_Date__c != Trigger.old[i].Expiration_Date__c) { 
                System.debug('-------old[i].Expiration_Date__c------------' +Trigger.old[i].Expiration_Date__c);
                 System.debug('-------new[i].Expiration_Date__c------------' +Trigger.new[i].Expiration_Date__c);
                Trigger.new[i].Record_Support_Expiration_Date_Sub_Text1__c=Trigger.old[i].Expiration_Date__c; //remove credit card entries prior to committing data to Salesforce
                 System.debug('------- Trigger.new[i].Record_Support_Expiration_Date_Sub_Text1__c------------' + Trigger.new[i].Record_Support_Expiration_Date_Sub_Text1__c);
                updateList.add(Trigger.new[i]);
            }
         }
     update updateList;
   } catch(Exception e) {
//      System.Debug('removeCCValue Trigger failed: '+e.getMessage()); //write error to the debug log
   }
}

Thanks in advance:))))

 

 

  • December 10, 2012
  • Like
  • 0

Hi!

I have a set of Fields should be update, please teach me how to do ,thanks!

 

Set<String> Fieldset = new Set<String>{'Fax','Website'};

account a1 = [select id,Fax,Website from account limit 1];
account a2 = [select id,Fax,Website from account limit 1 offset 1 ];

for (string Field1 : Fieldset ) {
     a1.Field1 = String.valueof(a2.Field1);       // Error : Invalid Field1 for SObject Account
     //update a1;
}

 

 

don't work in a loop

for(String field :fields)
{
accs[0].get(field) = accs[1].get(field); //Expression cannot be assigned (the get() Arguments should be Integer i) accs[0].field = accs[1].field; //Invalid field field for SObject Account }

and don't work just as a parameter

 

list<String> fields2 = new list<String>{'Fax','Website'};
accs[0].fields2[0] = accs[1].fields2[0];          //Invalid field fields2 for SObject Account

 

 can work when set  the exact Field Name

        accs[0].Fax = accs[1].Fax;   //List SObject Type
accs.Fax = accs.Fax; //SObject Type

 

 Regards

Few questions:

I have a class with 'State' and 'Number'. The combination should be unique, and should be the Name field for the table. I'm hitting some road blocks that I suspect are built-in limitations of SF:

 

  1. Is there a way to make the Name Field a formula? If there is, I haven't found it.
  2. Is there a way to require the Name Field to be unique?
  3. Is there a way to make any Formula Field unique?

One work-around would be using auto-increment for the Name, but this will show up on Lookup Fields, and that's a deal killer. Any suggestions?

Another would be a Trigger that sets the Name before the district is saved and checks for uniqueness. This seems a lot of work for what should be something easy, but I could do it.

 

Is there an elegant approach. What have people tried?

Hi folks,

 

I was wondering if it's possible to produce dynamic SOQL queries. I'll elaborate:

 

I have a class whose input is a string, let's call it str. I then use str to manipulate a double on an object record (rec), like so:

 

(double)rec.get(str)

 

I'd like to query just for this double, specified by the above code, as, at the moment, I'm running something like

 

for(Custom_Object__c rec: [select **loads of different doubles** from Custom_Object__c where **condition**]){

 

which is hitting the SOQL query limit. Is there a way of, in the for loop above, just using "selecting" the double specified by (double)rec.get(str)? i.e. if str was something like "Number_of_Days__c", the loop:

 

for(Custom_Object__c rec: [select (double)str from Custom_Object__c where **condition**]){

 

would yield the same value as:

 

for(Custom_Object__r rec: [select Number_of_Days__c from Custom Object__c where **condition**]){

 

Any help you can give would be massively appreciated.

 

Thanks,

Lee

Hello,

 

I have a validation rule right now that requires you to select a task type besides the default when creating a new task.  I recently ran into a problem when our marketing automation tool tries to make a task in salesforce.  On the marketing automation forum for creating a task it does not have the option of selecting a task type so it is set to default which does not comply with my validation rule.  I wanted to know if I could write a trigger that would be able to set the task type before insert when you change the priority to something else besides the default so it will comply with the validation rule.  Thanks.

  • December 03, 2012
  • Like
  • 0

I have an external .NET WCF Service that I am trying to invoke from outside the Salesforce sandbox.  One of the arguments in the .NET WCF Service function call is a byte array.  What is the appropriate conversion in APEX so that I can pass data to this function?

 

WSDL element:

<xs:elementminOccurs="0"name="FileContents"nillable="true"type="xs:base64Binary" />

 

 

Call to this:

String filecontents = BuildFile();
inputfile.FileName = 'SalesForceAddressFile.txt';
inputfile.FileContents = EncodingUtil.base64Encode(Blob.valueOf(filecontents));

 

When I look at the DataContract that was pulled in, the property is a String, but defined to the service as base64Binary.

 

Here is the DataContract code that was generated from the WSDL:

    public class FileObject {
        public String FileContents;
        public String FileName;
        private String[] FileContents_type_info = new String[]{'FileContents','http://www.w3.org/2001/XMLSchema','base64Binary','0','1','true'};
        private String[] FileName_type_info = new String[]{'FileName','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://schemas.datacontract.org/2004/07/CDITecServices','true','false'};
        private String[] field_order_type_info = new String[]{'FileContents','FileName'};
    }

 

 

 

 

But when I invoke the webservice, there is an error thrown and I have narrowed it down to this property.  What am I doing wrong?  I have UnitTests setup in an external program that test the web service outside of the call from SalesForce, so I know that the webservice functions properly.  If I set inputfile.FileContents to null, I can get from SalesForce to the web service and execute the web service method.  When I keep the code as above, and send a String using the EncodingUtil, it errors on the invoking of the web service method.