Current logged in user details

Dear @ixxxl,
What issue? This is not an issue - that's how the system works, for example, you can instead use user ID to get user's email and use it to populate the field.

@Nikita_Kurguzov i Use 2 different , unique emails , but in people picker field have the same person
This users have the same name and surname. and the accounts are created like 1 at he end of surname.
For example:
a.b@test.com
a.b1@test.com

and the result in people picker always is a.b1@test.com user ....

The only solution is to rename all such conflict users to make
a1.b@test.com

In this case it breaks inheritance of search and works correct. Only by email...

Dear @ixxxl,
So, what solution do you need if this is the current setup? If all emails have matching structure, you can check what user email is selected on change event and replace wrong email with correct one using JS, for example.

@Nikita_Kurguzov
Solution to work all by default and not to change every time email of existing user :slight_smile: this is a pain. To talk to every user, what' wrong with it's account.. and renaming affects over systems where they log in. can you please send me an example of JS, what do you mean about replace wrong email.
For now populate people picker is on new form, on load, pnp details of current user from User Profile.

Dear @ixxxl,
I need to know more information, for example, what code you use to populate the user field now, and what structure all emails have - they just have an extra 1 at the end of the email? It's possible to remove this 1 from the email with JavaScript if it's present.

@Nikita_Kurguzov
bossLevel1, bossLevel2, bossLevel3 - for now are DisplayName custom fields in User Profile, but i can replace them with the users emails.
about email structure:
we started to change some users, about 15 users have - name1.surname@company.com
Other have - name.surname1@company.com

with JS it will resolve, but it will be at one list, to apply to all processes creted , need to apply this JS to every list ?


function updateUserInfo(result) {
    var props = result.UserProfileProperties;
    var sec = "";
    var niv1 = "";
    var niv2 = "";
    var niv3 = "";
    var tip = "";
    var subdiv
    for (var i = 0; i < props.length; i++) {
        switch (props[i].Key) {
            case 'DENNIVEL1':
                //Form Field Internal name
                niv1 = props[i].Value;
                break;
            case 'DENNIVEL2':
                //Form Field Internal name
                niv2 = props[i].Value;
                break;
            case 'DENNIVEL3':
                //Form Field Internal name
                niv3 = props[i].Value;
                break;
            // Sharepoint or AD attribute  
            case 'SECTORFUNCTIE':
                //Form Field Internal name
                sec = props[i].Value;
                break;
            case 'TIPSUBUNITATE':
                //Form Field Internal name
                tip = props[i].Value;
                break;
            case 'Office':
                //Form Field Internal name
                fd.field('Num_x0103_r_x0020_de_x0020_tabel').value = props[i].Value;
                break;
            // Sharepoint or AD attribute 
            case 'DEP':
                //Form Field Internal name
                fd.field('Subdiviziunea').value = props[i].Value;
                break;
            case 'Title':
                //Form Field Internal name
                fd.field('Func_x021b_ia').value = props[i].Value;
                break;
            case 'bossLevel1':
                //Form Field Internal name
                fd.field('Boss_x0020_Level_x0020_1').value = props[i].Value;
                break;
            case 'bossLevel2':
                //Form Field Internal name
                fd.field('Boss_x0020_Level_x0020_2').value = props[i].Value;
                break;
            case 'bossLevel3':
                //Form Field Internal name
                fd.field('Boss_x0020_Level_x0020_3').value = props[i].Value;
                break;
            case 'codSubdiviziune':
                //Form Field Internal name
                fd.field('Cod_x0020_Subdiviziune').value = props[i].Value;
                break;
            case 'NOTIFICARE':
                //Form Field Internal name
                fd.field('Notificare').value = props[i].Value;
                console.log('notificare');
                break;
            case 'SolduriConcedii':
                //Form Field Internal name
                fd.field('zileConcediu').value = props[i].Value;
                break;
        }
    }
    var subdiv = niv1;
    if (niv2 != "") {
        subdiv += "/" + niv2
    }
    if (niv3 != "") {
        subdiv += "/" + niv3
    }
    fd.field('Subdiviziunea').value = subdiv;

    var sector = "";
    if (tip == "C") {
        sector = "Centrala";
    } else if (tip == "S") {
        sector = "Retail";
    } else if (sec == "IMM") {
        sector = "IMM";
    } else {
        sector = "Retail";
    }
    fd.field('Sector').value = sector;
    //daca sunt exceptii
    manageriExceptie(_spPageContextInfo.userId);
};

Dear @ixxxl,
I am not seeing any email use in this code, you're only using props[i].Key, which accesses directly to the current user's profile. What information do they have in their profile? New or old? It's always best to use the profile information as data source.

With JavaScript, we can make a crutch - manually check each field, and correct the email, but it might need to be applied to every field on every form, taking quite a bit of time to implement.

@Nikita_Kurguzov
in props[i].Key there are emails. bosslevel1,2,3 are customs User Profile attributes which are populated every 1 hour.

It's always best to use the profile information as data source.
How ?

Dear @ixxxl,
If you have an email, it can be changed like so:

var email = 'name.surname1@company.com';
if(email.indexOf('1@') > 0){
  var emailNew = email.replace('1@','@').replace('.','1.');
}

Of course, that's a crutch and it's better to fix emails in the user profile services, but it can help.