Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
法人番号をLightningWebComponentで取得する
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yoshi
September 21, 2022
Technology
92
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
AgentforceとSalesforceフローとSlackで実現する 「自走型エージェント」構築手順
yoshi17
0
150
Agentforce_ AIによるカスタマーサポートの変革
yoshi17
0
87
事前設定(ExperienceCloudの設定、テストデータ作成)
yoshi17
0
130
AWTT2026_ハンズオン(Agent Scriptサンプル)
yoshi17
0
10
レポート作成ワークショップ(サンプルデータ作成)
yoshi17
0
35
レポート作成ワークショップ(レポート作成例あり)
yoshi17
0
35
レポート作成ワークショップ(レポート作成例なし)
yoshi17
0
23
【付録】AI関連の重要用語集
yoshi17
0
260
【northernforce#54】AIの歴史と仕組みから学ぶAIエージェント入門
yoshi17
0
330
Other Decks in Technology
See All in Technology
2026TECHFRESH畢業分享會 - Lightning Talk - 打造精準高效的 MCP 設計模式與測試實務
line_developers_tw
PRO
0
1.2k
[AWS Summit Japan 2026]迷っているあなたへ_小さな一歩が、やがて自分を助けてくれる
sh_fk2
1
130
AI駆動開発を通して感じた、 AI時代のデザイナーの役割変化
whisaiyo
3
2.3k
2026 TECHFRESH 畢業分享會 - AI-Native 重塑軟體工程與虛擬講師
line_developers_tw
PRO
0
1.2k
Kiroで書いた 設計書 が AI レビューの 採点基準 になる
ezaki
0
130
Kubernetesにおける学習基盤とLLMOpsの概要
ry
1
320
自宅LLMの話
jacopen
1
610
脱SaaS!FDEを支えるプロビジョニングと分離設計
knih
0
240
いまさら聞けない「仕様駆動開発入門」 〜AI活用時代の開発プロセスを考える〜
findy_eventslides
2
160
自律型AIエージェントは何を破壊するのか
kojira
0
160
2026TECHFRESH畢業分享會 - Lightning Talk - E起 See See : 電商推薦讀心術? 數據說了算
line_developers_tw
PRO
0
1.2k
自分が詳しくない領域でAIを使う #プロヒス2026
konifar
6
1.6k
Featured
See All Featured
Visualization
eitanlees
152
17k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.4k
Ruling the World: When Life Gets Gamed
codingconduct
0
260
Code Review Best Practice
trishagee
74
20k
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
Context Engineering - Making Every Token Count
addyosmani
9
970
Raft: Consensus for Rubyists
vanstee
141
7.5k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Crafting Experiences
bethany
1
180
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
560
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; } }