Profile And RecordType Relation ?
SFDC Metadata Api To Get Profile ProfileRecordTypeVisibility
1
2
3
4
5
6
7
8
| var fullNames = [ 'Guest', 'Admin' ];
conn.metadata.read('Profile', fullNames, function(err, metadata) {
if (err) { console.error(err); }
for (var i=0; i < metadata.length; i++) {
var meta = metadata[i];
console.log( meta);
}
});
|
IP address Limit
1
2
3
4
5
6
7
8
| conn.metadata.update('Profile', {
fullName: '{Profile Name}',
loginIpRanges: [
{
startAddress:'0.0.0.0',
endAddress:'255.255.255.255'
}]
});
|
Get Field-Level Security
1
2
3
4
5
6
7
8
| conn.metadata.read('Profile', ['{Profile Name}'], function(err, metadata) {
if (err) { console.error(err); }
console.log(['SObject', 'Field', 'Readable', 'Editable'].join(','));
meta.fieldPermissions.forEach(function(permission){
var fieldInfo = permission.field.split('.');
console.log([fieldInfo[0], fieldInfo[1], permission.readable, permission.editable].join(','));
});
});
|
Set Field-Level Security
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| var fieldPermissions=[];
fieldPermissions.push({
field: 'YourSObject.Filed',
readable: true,
editable: true
});
conn.metadata.update('Profile', {
fullName: '{Profile Name}',
fieldPermissions: fieldPermissions
},
function(err, userInfo) {
console.log(err);
console.log(userInfo);
}
);
|
describe sobject
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| var objs = ['Demo__c','Blog__c'];
for (var i = 0; i < objs.length; i++) {
var sobject = objs[i];
conn.sobject(sobject).describe(function(err, meta) {
console.log(meta);
// var fieldPermissions=[];
// for (var j=0; j < meta.fields.length; j++ ) {
// fieldPermissions.push({
// field: sobject + '.' + meta.fields[j].name,
// readable: true,
// editable: true
// });
// }
// console.log('>>>>>fieldPermissions');
// console.log(fieldPermissions);
// conn.metadata.update('Profile', {
// fullName: [ 'Guest', 'Admin' ],
// fieldPermissions: fieldPermissions
// },
// function(err, results) {
// console.log(err);
// console.log(results);
// });
});
}
|
Object List
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| var data = [];
var _request = {
url: '/services/data/v' + page.conn.version + '/sobjects?' + Date.now(),
method: 'get', // get,post...
body: '',
headers : {'Content-Type' : 'application/json'}
};
conn.request(_request, function(err, res) {
page.setfooter(true);
if (err) {
return console.error(err);
}
// console.log('Num of SObjects : ' + res.sobjects.length);
// console.log(res.sobjects);
for (var i = 0; i < res.sobjects.length; i++) {
var sobject = res.sobjects[i];
// mylog('>>>>>>sobject ' + sobject.name);
// console.log(sobject);
if(sobject.name.endsWith('__ka')
|| sobject.name.endsWith('__kav')){
console.log(sobject);
}
}
});
|