You need to sign in to do that
Don't have an account?
krish99
Prevent duplicates in custom webservice soap
HI,
I am working with custom webservice class in sfdc, by using this custom class php developers connect to salesforce
i have one probelm how can we avoide the duplicates ..
For Example---for php to sfdc we created a account A, again from php same account is send at that time how php people get error message record already exist, for that how can i implement the custom webservice class in salesforce can any one help me.
Hi,
Lets solve the problem one by one. First lets discuss how we can stop duplication of account record on the basis of account Name. You need to have a member field in response, which will have error message(you can plan it according to your business objective). First create the instance of response object and then check for duplication of account record. I have modified your code snippet for account insertiong. Try to run this first, if account duplication issue solve, then we can discuss next problem.
Let me know if you see any issue with this.
Happy to help you!
Regards,
Digamber Prasad
All Answers
Hi,
How to do you determine that account is duplicate? Is it on the basis of only Name or may be combination of fields? In your web service method you can check against combination of these fields and if found the record, we can send custom error to caller.
However there are other ways too. I will be able to help you with exact solution if you can share snippet of your code.
Happy to help you!
Regards,
Digamber Prasad
@digamberlucky
once check it my code is correct or not
Looks like you have done copy-paste of some part of your code, which is fine understanding that you don't want to expose your business to outside world. The only thing I can think of wrong in above code is
You can't have Id before you are inserting a record.
Also, could you please answer my above question and that is how you determine if an account is unique or not? Is it just name of Name of account or the combination of all fieds sent as part of request?
If you tell me about criteria to determine if account is unique or not, I can give you snippet of code which will help you.
Happy to help you!
Regards,
Digamber Prasad
@digamberlucky
with account name
@digamberlucky
Actully i want to implement a custom webservice by using soap i am getting the fields from php
the fields which i am getting from external service
//Account Releated Fields
accountName, accountNumber, billingStreet, billingCity, billingState, billingZip, billingCountry;
////Contact Releated Fields
firstname, Lastname,email;
// Opportunity Releated Fields
Name,closeDate, Stage;,Amount;
//Quote Releated Fields
quoteNumber; Name; Status; expDate;
based upon these i have to implement a custom webservice after insert all values into sfdc
i have to insert quotelineiteams so i have to check product is exist in sfdc or not,
if not means i have to insert
this is my requriment so help me how can i develop a custom webservice for above requriment
I am confused, in start of this conversation you said that you want to send error message if account already exists and now you are talking about inserting QuoteLineItems. Lets take one requirement at a time. Let me know your first requirement.
Regards,
Digamber Prasad
Hi,
@digamberlucky
Actually my requriment is i want to insert quotes which are coming from external system.
For this qoutes insertion i have to first insert accounts,contacts,opportunities.then quotes.
so i begin my webservice first with account insertion.
Hi,
Lets solve the problem one by one. First lets discuss how we can stop duplication of account record on the basis of account Name. You need to have a member field in response, which will have error message(you can plan it according to your business objective). First create the instance of response object and then check for duplication of account record. I have modified your code snippet for account insertiong. Try to run this first, if account duplication issue solve, then we can discuss next problem.
Let me know if you see any issue with this.
Happy to help you!
Regards,
Digamber Prasad
@digamberlucky
Hi thanq for givinig reply then in which way i can test this class my final business class is
Hi,
First of all, in your ResponseClass, errorMessage variable needs to be webservice, as shown in below code snippet.
To test it, you can always use SOAPUI. Or if you have the guy who will finally consume your wsdl, you can give him wsdl upto this point and ask him to do testing, which is not recommended. So, I will still suggest you should go with SOAPUI, which is easy to use.
Regards,
Digamber Prasad
@digamberlucky
Thanq for Replying, But I have a doubt without writing the test class how can we move sandbox to production,if we test our webservice by using SoapUI means webservice code coverage is increased, without writing of test class.
could you please help me how can i insert contact to particular account, opportunity to particular Account, quote into particular
opportunity, shall i use same webservice or i have to create another webservice program. if same webservice means how can i insert that values.
////Contact Releated Fields
firstname, Lastname,email;
// Opportunity Releated Fields
Name,closeDate, Stage;,Amount;
//Quote Releated Fields
quoteNumber; Name; Status; expDate;
Hi,
You don't need to write separate web service for all these objects, as all can be clubbed into same web service. Please see below code snippet to give you an idea about how you can do this:-
Hopefully it will help you!
Regards,
Digamber Prasad
@digamberlucky
Hi Thanks very very very much..........giving reply to me.
I have one more doubt After creation of quote i want to insert quotelineiteams to particular quote.
for quoteline iteams i have to insert product details
for me i am getting fields from external system is
product Name ,product code(SKU) ,description,orginal price ,quantity,price.
for this first i have to check getting product exist in salesforce or not, if exist means it automatically asign to particular quote,
else i have to create a product.and then account---to--quote
can you give me idea about how can i create a quote and how it is asign to a standard price book.
how it can be asign to particular quote.
Hi,
What is unique criteria for creation of product, is it only product key or combination of more than one field?
Happy to help you!
Regards,
Digamber Prasad
@digamberlucky
HI,
Product code is the unique item for creating record.
Hi,
I hope below code snippet will help you.
Let me know if you have any other problem.
Happy to help you!
Regards,
Digamber Prasad
@prasad
HI,
when i am testing my code means i am getting folling error i am using soapUi tool if u need means i will give my code also.to test
Hi,
Could you please post the code snappet from SoapUI of Request which you are trying to send to salesforce for login? Looks like you are missing organizationID.
Happy to help you!
Regards,
Digamber Prasad
@digamberlucky
Below code is my sample webservice class
Hi,
Looking into it. Will get back to you ASAP.
Happy to help you!
Hi,
I have run this and can't see any problem. Do you have skype id, where we can do screen share to see exactly what you are trying to do?
Happy to help you!
@digamberlucky
ok thanq for reply, i will also run again my program and inform you.
@digamberlucky
Hi,
when i use below webserivce means just account is creating,not contact may i know how can i insert contact into particular
account
Hi,
Happy that it atleast now you can insert account. You can use below code snippet to insert both contact & opportunity:-
Let me know if you have any specific question.
Happy to help you!
@DigamberLucky
Hi,
your skype id is not visiable in skype directory once check and send me exact id.
Hi,
You need to insert contact before sending response. Something like below code snippet:-
Let me know if you have any question.
Happy to help you!
Hi,
I assume you have already inserted quote record and name of variable is 'quote'. Also, on QuoteLineItem, only mandatory field is Name. You can use below code snippet to insert quotelineitem record with association of quote.
You can modify it to meet your requirement.
Hi,
Probably below will help you:-
Please let me know if you stil lhave any question.
Hi,
Please try below code, now product record will be active.
Let me know if you have any question.
@digamberlucky
HI,
first time i created a account name----Google
for that account contact have --->> user1
insert successfully,
again same acount is send by third party at that time it shows that account already exist,,,,but in this case the we are sending same account but USER2 details
but when test this at that time USER2 details have to map to GOOGLE but it is not ...MAY i know how can i achieve this..
Hi,
I have modified code below and you can modify it as per your requirement:-
Let me know if you have any question.
HI,
How can i insert multiple products at a time into sfdc.
Hi,
For error related to Product record, can you please replace your code with below code snippet & let me know if you still see any issue:-
Hi,
I have modified your code base for product part
Let me know if you have any question.
Hi,
You can refer below code for inserting quotelineitem:-
Let me know if you have any question.
Hi,
Updated code for QuoteLineItem will look like:-
Let me know if you have any question.
Hi,
Could you please try below code snippet to insert QuoteLineItem:-
Let me know if you still see any problem.