We can create or update Remote Site Settings in Apex using Metadata API.
You can either download Metadata API WSDL from Salesforce and generate apex class by clicking on Generate from WSDL button.
Or you can download the MetadataService class from below link:
MetadataService.cls
Below is sample to code to create remote site settings.
Note:
Create Custom Metadata Types Using Metadata API
Create Update Custom Label by Using Metadata API
You can either download Metadata API WSDL from Salesforce and generate apex class by clicking on Generate from WSDL button.
Or you can download the MetadataService class from below link:
MetadataService.cls
Below is sample to code to create remote site settings.
Execute this static method from execute anonymous and check if records created or not.
MetadataAPIUtility.createRemoteSiteSettings();
Below is snapshot of remote site settings created
- I have used upsertMetadata method. If you want to only insert new remote site setting, then use insertMetadata method
- fullname property is considered in order to decide whether remote site setting needs to be created or updated.
Hope this will help!!!
Create Custom Metadata Types Using Metadata API
Create Update Custom Label by Using Metadata API
Hi, I'm getting this error:
ReplyDeleteError: Method does not exist or incorrect signature: void createService() from the type MetadataAPIUtility line 24 column 52
Hi,
DeleteI have updated code.
Hello ,
ReplyDeletethanks for this tutorial (very useful)
I encounter an error when trying to execute the code in anonymous MetadataAPIUtility.createRemoteSiteSettings();
Line: 13497, Column: 1
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
I don't know why because i'm trying to udpate any record other than the remote site settings. Any idea ?
NO problem: I found my error... => there was something i was trying to update before creating the remotesite Settings
DeleteHi,
ReplyDeleteHow can i fetch remote site setting records using apex?
Hi Raj,
DeleteYou can use tooling API to fetch remote site settings. Execute below code in developer console which uses tooling API to get remote site settings details:
HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.setHeader('Content-Type', 'application/json');
String domainUrl=URL.getSalesforceBaseUrl().toExternalForm();
system.debug('********domainUrl:'+domainUrl);
req.setEndpoint(domainUrl+'/services/data/v44.0/tooling/query/?q=Select+EndpointUrl,SiteName+from+RemoteProxy');
req.setMethod('GET');
Http h = new Http();
HttpResponse res = h.send(req);
system.debug(res.getBody());
Now parse the JSON response.
Hi,
ReplyDeleteI'm Trying to create remote site Setting in apex using Metadata Service.But i'm Unable to create, It says it 'Unauthorized endpoint'.The remote site is my Base URL,any Idea to resolve this
Thanks in advance.
Hi Ankit,
DeleteI am getting same issue. Are you able to resolve this issue?
Hi,
DeleteIf we are creating it of the first time and it is not available in remote site setting then we need to create remote site from VF page in JS, because if we hit an callout in apex we need that in remote site but it will not apply for Visualforce JS
The time has arrived now IT staff can easily perform a unified desktop management for remote workers, remote offices, and local networked users task list templates
ReplyDeleteHi,
ReplyDeleteCan we use this as a part of managed package, to update subscriber org
very interesting keep posting. https://europa-road.eu/hu/gepszallitas-miskolc.php
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteDid you figure out how to query for the list of existing RemoteSiteSettings at all?
ReplyDeleteThanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. web-agency
ReplyDeleteThanks for sharing the post.. parents are worlds best person in each lives of individual..they need or must succeed to sustain needs of the family. sviluppo sito ecommerce
ReplyDeleteThis is a truly good site post. Not too many people would actually, the way you just did. I am really impressed that there is so much information about this subject that have been uncovered and you’ve done your best, with so much class. If wanted to know more about green smoke reviews, than by all means come in and check our stuff. sites like fiverr australia
ReplyDeletePretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. WordPress Developer Brisbane
ReplyDeleteI haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us.
ReplyDeletequenza software
I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people.
ReplyDelete먹튀검증커뮤니티
Thank you for some other informative blog. Where else could I get that type of information written in such an ideal means? I have a mission that I’m just now working on, and I have been at the look out for such information.
ReplyDeleteSEO Company Australia
I really appreciate your efforts. Can you please provide test class for MetadataAPIUtility class.
ReplyDeletePositive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include.
ReplyDeletemerchant services iso
Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!THANKS!!!!!!
ReplyDeletehow to start a payment gateway company
This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post!
ReplyDeleteselling credit card terminals
ReplyDeleteThanks for sharing nice information with us. i like your post and all you share with us is uptodate and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job.
how to become an iso agent
Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place..
ReplyDeleteiso partner program
Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place..
ReplyDeletehow to sell merchant services
Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work.
ReplyDeleteFlyttstädning Boden
Admiring the time and effort you put into your blog and detailed information you offer!.. Website Hosting
ReplyDeleteGood website! I truly love how it is easy on my eyes it is. I am wondering how I might be notified whenever a new post has been made. I have subscribed to your RSS which may do the trick? Have a great day! psychiatric service dog letter
ReplyDeleteHello I am so delighted I located your blog, I really located you by mistake, while I was watching on google for something else, Anyways I am here now and could just like to say thank for a tremendous post and a all round entertaining website. Please do keep up the great work. 안전놀이터
ReplyDeleteI high appreciate this post. It’s hard to find the good from the bad sometimes, but I think you’ve nailed it! would you mind updating your blog with more information? 온라인릴게임
ReplyDeleteI have read your article, it is very informative and helpful for me.I admire the valuable information you offer in your articles. Thanks for posting it.. 메이저사이트
ReplyDeleteGreat article Lot's of information to Read...Great Man Keep Posting and update to People..Thanks http://www.shuttlesky.in/
ReplyDeleteA web manage membership office probably won't be an electronic run yet a significant part of the much more expert membership endeavors moreover offer the best web facilitating uncommon arrangements utilizing the net.https://onohosting.com/
ReplyDeleteHost your domain names, emails and website using the super fast dubai best web hosting in dubai, Affordable servers based in Dubai UAE, Cpanel/Plesk Hosting, Free SSL and Site.
ReplyDeletehttps://maps.google.lu/url?q=https%3A%2F%2Fsite789.com
ReplyDeletesite852
ReplyDeleteThanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts. 먹튀검증사이트
ReplyDeletemtgumc
ReplyDeleteค่ายสล็อตชั้นนำ เกมสล็อตเเตกง่าย เกมสล็อตยอดฮิตทั้งเก่า เเละใหม่ ทั้งหมดนี้รวมไว้ในเว็บไซต์เดียว ambbet เว็บหลัก สล็อตเว็บตรงไม่ผ่านเอเย่นต์ โดยผู้เล่นสามารถปั่นสล็อตผ่านเว็บ ambbets.com ได้ทันที เพียงเเค่เติมเงินเล่นสล็อต หรือ สมัครสมาชิก รับโบนัสฟรี เครดิตฟรี โปรโมชั่นเพียบ !! กดรับเอง ไม่มีเงื่อนไข เปิดให้บริการตลอด 24 ชั่วโมง.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi all, I am using the same utility to create one lightning page to make org connections but whenever some one is giving any other connection name then the previous one it is creating the two remote site setting with the different one.
ReplyDeleteIs there any way we somehow can update the existing RemoteTypeSetting record.
I have tried using the upsert and update method of the utility(MetaDataService) but that is not helpful, It is not working. It is only creating the new record only.
amazing information and brilliant work by this company services. Author: flyttstädning Växjö
ReplyDeleteinteresting topic, i loved it, hope you will continue sharing this kind of information further in future. editor: flyttstädning borås
ReplyDeleteit was very helpful. publisher:
ReplyDeleteso much interesting
ReplyDeleteWow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also visit Now zoopup.
ReplyDelete