サーバレス練習帳

着眼大局着手小局

【python】Salesforceのurlから対象画面か否か判定する

Salesforce Classicの特定のタスたむオブジェクトの編集 及び 新規画面のみを対象にしたい場合です。

def matchPage(alRegexUrl,strTargetUrl):#一致判定
	flRes = True
	for strRegexUrl in alRegexUrl :
		if not(strTargetUrl.find(strRegexUrl) > -1) :
			flRes = False
	return flRes

def myTest():
	strRegexUrl = ['https://ap.salesforce.com/800','retURL']

	# カスタムオブジェクトの編集画面
	strUrl01 = 'https://ap.salesforce.com/80010000000CRTS/e?retURL=%2F80010000000CRTS&_CONFIRMATIONTOKEN=VmpFPSxNakF4T0MweE1TMHhORlF3T0RvMU16b3dNUzQyTmpCYSxzaTZVMUEzZ19fRGFBUDZSaDRVMXJpLE9EVXhZV0Zo&common.udd.actions.ActionsUtilORIG_URI=%2F80010000000CRTS%2Fe'
	print(matchPage(strRegexUrl,strUrl01))

	# カスタムオブジェクトの新規画面
	strUrl02 = 'https://ap.salesforce.com/800/e?retURL=%2F800%2Fo'
	print(matchPage(strRegexUrl,strUrl02))

	# カスタムオブジェクトの参照
	strUrl03 = 'https://ap.salesforce.com/80010000000CRTS'
	print(matchPage(strRegexUrl,strUrl03))