• surendra kumar 7
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
im write the trigger duplicate name on student object its show an error

Error :required (...)+ loop did not match anything at input 'trigger'
trigger duplicatename on student__c (before insert)
{
    list<student__c> stlist=trigger.new;
    list<student__c> stnewlist=new list<student__c>();
    for(student__c st:stlist)
    {
        stnewlist=[select id,name from student__c where name=st.name];
        if(stnewlist.size()>0)
        {
            st.adderror('you cant insert a record with duplicate name');
        }
    }
        }  

hi could u give the soluti

trigger salesContacts on Opportunity (after insert){
List<OpportunityShare> sharesToCreate = new List<OpportunityShare>();
List<OpportunityTeamMember> oppteam = new List<OpportunityTeamMember> ();

if(trigger.new[0].Partner_User__c != null) {
OpportunityShare oshare = new OpportunityShare();
oshare.OpportunityAccessLevel = 'Edit';
oshare.OpportunityId = trigger.new[0].Id;
oshare.UserOrGroupId = trigger.new[0].Partner_User__c;
sharesToCreate.add(oshare);

OpportunityTeamMember ot = new OpportunityTeamMember();
ot.OpportunityId = trigger.new[0].Id;
ot.UserId = trigger.new[0].Partner_User__c;
ot.TeamMemberRole = 'Reseller';
oppteam.add(ot);
}


// do the DML to create shares
if (!sharesToCreate.isEmpty())
insert sharesToCreate;

// do the DML to create shares
if (!oppteam.isEmpty())
insert oppteam;
}

on for above error given the code below

 

I am using a standard page on which there is a button in which JavaScript code is written. It is calling a Controller (Class).

When I ever used click on the button,It gives me error:

A problem with the OnClickJavaScriptforthis button or link was encountered:
unterminated
string literal.

Javascript&colon;

try
{
  alert
('hi1');
}
catch(Err)
{
  alert
('Error  in creation'+Err);
}

After searching and done some hit and trial,used a simple alert code above.

I found that. whenever i used data where there is a new line space between them i.e. data in multiple times.This error encounters no matter if you are using that particular field in JavaScript code and class or not.

 

 

 

What i am trying to say is : i am not using that field anywhere in the JavaScript code. I am just simply using alert('hi');.

Nothing else you can also try just create a custom button on sfdc detail page ,call JavaScript on it and put data in any Long text area field with multiple line.You will get same error. Any work around for this?

Hi,

    i will try to run this class, i got an error like   <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><CreateCustomerProfileResponse xmlns="https://api.authorize.net/soap/v1/"><CreateCustomerProfileResult><resultCode>Error</resultCode><messages><MessagesTypeMessage><code>E00007</code><text>User authentication failed due to invalid authentication values.</text></MessagesTypeMessage></messages><customerProfileId>0</customerProfileId></CreateCustomerProfileResult></CreateCustomerProfileResponse></soap:Body></soap:Envelope>

 

Public class callExternalWS 
    { 
        public void invokeExternalWs() 
        { 
            HttpRequest req = new HttpRequest(); 
            //Set HTTPRequest Method 
            req.setMethod('POST'); 
            req.setEndpoint('https://api.authorize.net/soap/v1/Service.asmx'); 
            req.setMethod('POST'); 
            req.setHeader('Content-Type', 'text/xml; charset=utf-8'); 
            req.setHeader('SOAPAction', 'https://api.authorize.net/soap/v1/CreateCustomerProfile'); 
            string b =   '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'+ 
                          '<soap:Body><CreateCustomerProfile xmlns="https://api.authorize.net/soap/v1/">'+ 
                          '<merchantAuthentication><name>8j4W5UyB</name>'+ 
                          '<transactionKey>7mR2ah8655gLSR8q</transactionKey></merchantAuthentication>'+ 
    '<profile><description>description</description>'+ 
                          '<email>sforce2009@gmail.com</email>'+ 
                          '<paymentProfiles>'+ 
                          '<CustomerPaymentProfileType><customerType>individual</customerType>'+ 
    '<payment><creditCard><cardNumber>6011000000000012</cardNumber>'+ 
                          '<expirationDate>2009-12</expirationDate></creditCard>'+ 
                          '</payment></CustomerPaymentProfileType></paymentProfiles></profile>'+ 
                          '</CreateCustomerProfile></soap:Body></soap:Envelope>'; 
            req.setBody(b); 
            Http http = new Http(); 
            try { 
              //Execute web service call here        
              HTTPResponse res = http.send(req);    
              //Helpful debug messages 
              System.debug(res.toString()); 
              System.debug('STATUS:'+res.getStatus()); 
              System.debug('STATUS_CODE:'+res.getStatusCode()); 
              System.debug('STATUS_CODE:'+res.getBody()); 
            //YOU CAN ALWAYS PARSE THE RESPONSE XML USING XmlStreamReader  CLASS 
           } catch(System.CalloutException e) { 
                //Exception handling goes here.... 
         }        
    } 
    }

 

 

 thanks

sravani