Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
法人番号をLightningWebComponentで取得する
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yoshi
September 21, 2022
Technology
100
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
法人番号をLightningWebComponentで取得する
Yoshi
September 21, 2022
More Decks by Yoshi
See All by Yoshi
人とAIが共創する ガードレール設計
yoshi17
0
100
AgentforceとSalesforceフローとSlackで実現する 「自走型エージェント」構築手順
yoshi17
0
260
Agentforce_ AIによるカスタマーサポートの変革
yoshi17
0
150
事前設定(ExperienceCloudの設定、テストデータ作成)
yoshi17
0
250
AWTT2026_ハンズオン(Agent Scriptサンプル)
yoshi17
0
33
レポート作成ワークショップ(サンプルデータ作成)
yoshi17
0
54
レポート作成ワークショップ(レポート作成例あり)
yoshi17
0
57
レポート作成ワークショップ(レポート作成例なし)
yoshi17
0
39
【付録】AI関連の重要用語集
yoshi17
0
310
Other Decks in Technology
See All in Technology
スキマバイトという雇用形態は存在しないので、雇用期間1日のアルバイト契約を事業者とワーカーが結ぶ手続きを支えるのがタイミーなんです
akitoshiga
0
200
その Valkey 使いこなしていますか?
onk
PRO
5
1.6k
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
350
Active Record Connection Adaptersにおける長年の課題に再び取り組む
yahonda
0
200
分析の民主化を支えるメタデータ整備の実践
kakehashi
PRO
4
1.4k
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
190
Rustuna: Rustによる高速なOptuna実装
pfn
PRO
0
190
Kiro Crewをはじめよう
kizawa2020
1
160
エンタメ企業のM&Aを支えるデータ基盤 ― 統合から店舗のリアルタイム分析まで / Data Engineering Summit 2026
genda
0
190
re:Invent初参加で変わったこと、2回目にやってみたいこと(JAWS-UG彩の国埼玉 #12)
mhrtech
2
240
Benchmarking Disaggregated Serving on vLLM + Dynamo with a Real Coding-Agent Workload
nttcom
1
190
継続的なAIコスト最適化
bgpat
1
350
Featured
See All Featured
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
Large-scale JavaScript Application Architecture
addyosmani
516
110k
Skip the Path - Find Your Career Trail
mkilby
1
260
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
330
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
370
Embracing the Ebb and Flow
colly
88
5.2k
It's Worth the Effort
3n
188
29k
The Cult of Friendly URLs
andyhume
79
7k
How to Talk to Developers About Accessibility
jct
2
580
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
330
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
570
Transcript
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 1 / 8 ⽬的 取引先ごとに法⼈番号を管理するため 背景 インボイス制度により企業は「区分記載請求書」に「登録番号」、「適⽤税率」及び「消費税額等」の記載 が追加された書類やデータを交付・保存する必要がある
https://www.nta.go.jp/taxes/shiraberu/zeimokubetsu/shohi/keigenzeiritsu/invoice_about.htm 登録番号の構成は、次のとおりです 法⼈番号を有する課税事業者 「T」(ローマ字) + 法⼈番号(数字13桁) 上記以外の課税事業者(個⼈事業者、⼈格のない社団等) 「T」(ローマ字) + 数字13桁(注) (注)13桁の数字には、マイナンバー(個⼈番号)は⽤いず、法⼈番号とも重複しない事業者ごとの番号 になります。 本記事でやること 経済産業省から提供されている法⼈データ付与ツールを⽤いてSalesforceのLightningWebComponent経由で 取得し、法⼈名と法⼈番号をSalesforceの取引先へ保存する 法⼈番号付与ツール https://info.gbiz.go.jp/tools/nayose/index.html 利⽤申請ページから申請を⾏い、APIキーを取得する https://info.gbiz.go.jp/hojin/user_registration/application
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 2 / 8 実装結果 1.取引先データを表⽰ 2.法⼈番号検索セクションの検索ボタンをクリック 3.該当する法⼈を選択 4.保存ボタンをクリック
5.法⼈名(取引先名)と法⼈番号が書き換わっていることを確認
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 3 / 8 実装内容 LightningWebComponent searchCorporateNumber searchCorporateNumber.html <template>
<lightning-card title="法⼈番号検索"> <div class="slds-var-m-around_medium"> <lightning-button variant="brand" label="検索" title="SearchCorporateNumber" onclick={handleClick} record-id={recordId} class="slds-m- left_x_medium"></lightning-button> </div> </lightning-card> </template> searchCorporateNumber.js import { LightningElement, api, track, wire } from 'lwc'; import searchCorporateNumber from '@salesforce/apex/CorporateInformationController.searchCorporateNumber'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; export default class SearchCorporateNumber extends LightningElement { @api recordId; @track companyInfo; handleClick() { searchCorporateNumber({ accountId: this.recordId }) .then(result => { this.companyInfo = JSON.stringify(result); this.companyInfoMessage = JSON.parse(JSON.stringify(result)) ["message"]; if (this.companyInfoMessage == "200 - OK.") { const e = new CustomEvent('clickbutton', { detail: this.companyInfo}); this.dispatchEvent(e); } else { const evt = new ShowToastEvent({ message: '企業情報の候補がありません', variant: 'info', }); this.dispatchEvent(evt); } }); }
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 4 / 8 }
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 5 / 8 searchCorporateNumber.js-meta.xml <?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle
xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>55.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__AppPage</target> <target>lightning__RecordPage</target> <target>lightning__HomePage</target> </targets> </LightningComponentBundle> corporateNumber corporateNumber.html <template> <c-search-corporate-number onclickbutton={setCompanyInfo} record-id= {recordId}></c-search-corporate-number> <template if:true={companyInfo}> <lightning-card> <lightning-radio-group class="slds-var-m-around_medium" name="radioGroup" label="検索結果" options={options} value={value} onchange={handleChange} type="radio"> </lightning-radio-group> <lightning-button variant="brand" label="保存" title="SaveCorporateNumber" onclick={updateAccountData} class="slds-var-m-around_medium slds- m-left_x_medium"></lightning-button> </lightning-card> </template> <template if:false={companyInfo}> </template> </template>
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 6 / 8 corporateNumber.js import { track,LightningElement,api,wire }
from 'lwc'; import updateAccount from '@salesforce/apex/CorporateInformationController.updateAccount'; import wireSimpleOrComplexData from '@salesforce/apex/CorporateInformationController.wireSimpleOrComplexData'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; export default class CorporateNumber extends LightningElement { @track companyInfo; @track options = []; @track selectedIndex; @api get recordId() { return this.accountId; } set recordId(value) { this.accountId = value; } wiredData; accountId; account; error; @wire(wireSimpleOrComplexData, { accountId: '$_accountId' }) wiredData(result) { this.wiredData = result; if (result.data) { this.account = { ...result.data.accountFromServer }; } else { console.log(result.error); } } setCompanyInfo(event) { this.options = ""; this.companyInfo = JSON.parse(event.detail)["hojin-infos"]; for(var index in this.companyInfo){ const option = { label: this.companyInfo[index].name + '(' + this.companyInfo[index].corporate_number + ') ' + this.companyInfo[index].location, value: index }; this.options = [ ...this.options, option ]; } } handleChange(event) { this.selectedIndex = event.target.value;
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 7 / 8 } updateAccountData() { let newAccount
= {}; newAccount.Id = this.recordId; newAccount.Name = this.companyInfo[this.selectedIndex].name; newAccount.AccountNumber = this.companyInfo[this.selectedIndex].corporate_number; updateAccount({account: newAccount}) .then(() => { const evt = new ShowToastEvent({ message: '保存しました', variant: 'success', }); this.dispatchEvent(evt); this.companyInfo = null; setTimeout(() => { eval("$A.get('e.force:refreshView').fire();"); }, 1000); }) .catch(error => { const evt = new ShowToastEvent({ message: '保存できませんでした', variant: 'error', }); this.dispatchEvent(evt); console.log(error); }); } } corporateNumber.js-meta.xml <?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>55.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__AppPage</target> <target>lightning__RecordPage</target> <target>lightning__HomePage</target> </targets> </LightningComponentBundle>
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 8 / 8 Apex CorporateInformationController.cls public with sharing
class CorporateInformationController { @AuraEnabled (cacheable=true) public static Map<String, Object> wireSimpleOrComplexData(String accountId) { Map<String, Object> result = new Map<String, Object>(); Account acc = [SELECT Id, Name, AccountNumber FROM Account WHERE Id =: accountId LIMIT 1]; result.put('accountFromServer', acc); return result; } @AuraEnabled public static Map<String, Object> searchCorporateNumber(String accountId){ try { String accountname = [SELECT Name FROM Account WHERE Id =: accountId].Name; HttpRequest req = new HttpRequest(); String searchKey = EncodingUtil.urlEncode(accountName, 'UTF-8'); req.setEndpoint('https://info.gbiz.go.jp/hojin/v1/hojin?name=' + searchKey + '&page=1&limit=50'); req.setMethod('GET'); req.setHeader('Accept','application/json'); req.setHeader('X-hojinInfo-api-token','利⽤申請して取得したAPIキー'); Http http = new Http(); HTTPResponse res = http.send(req); Map<String, Object> mapJson = (Map<String, Object>)JSON.deserializeUntyped(res.getBody()); return mapJson; } catch (Exception e) { throw new AuraHandledException(e.getMessage()); } } @AuraEnabled public static Account updateAccount(Account account) { update account; return account; } }